home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1995 #2 / Amiga Plus CD - 1995 - No. 2.iso / internet / faq / englisch / unix < prev    next >
Encoding:
Text File  |  1995-04-11  |  181.3 KB  |  4,430 lines

  1. Archive-name: unix-faq/faq/contents
  2. Version: $Id: contents,v 2.5 1994/04/28 19:25:03 tmatimar Exp tmatimar $
  3.  
  4. The following seven articles contain the answers to some Frequently Asked
  5. Questions often seen in comp.unix.questions and comp.unix.shell.
  6. Please don't ask these questions again, they've been answered plenty
  7. of times already - and please don't flame someone just because they may
  8. not have read this particular posting.  Thank you.
  9.  
  10. This collection of documents is Copyright (c) 1994, Ted Timar, except
  11. Part 6, which is Copyright (c) 1994, Pierre Lewis and Ted Timar.
  12. All rights reserved.  Permission to distribute the collection is
  13. hereby granted providing that distribution is electronic, no money
  14. is involved, reasonable attempts are made to use the latest version
  15. and all credits and this copyright notice are maintained.
  16. Other requests for distribution will be considered.  All reasonable
  17. requests will be granted.
  18.  
  19. All information here has been contributed with good intentions, but
  20. none of it is guaranteed either by the contributors or myself to be
  21. accurate.  The users of this information take all responsibility for
  22. any damage that may occur.
  23.  
  24. Many FAQs, including this one, are available on the archive site
  25. rtfm.mit.edu in the directory pub/usenet/news.answers.
  26. The name under which a FAQ is archived appears in the "Archive-Name:"
  27. line at the top of the article.  This FAQ is archived as
  28. "unix-faq/faq/part[1-7]".
  29.  
  30. These articles are divided approximately as follows:
  31.  
  32.       1.*) General questions.
  33.       2.*) Relatively basic questions, likely to be asked by beginners.
  34.       3.*) Intermediate questions.
  35.       4.*) Advanced questions, likely to be asked by people who thought
  36.            they already knew all of the answers.
  37.       5.*) Questions pertaining to the various shells, and the differences.
  38.       6.*) An overview of Unix variants.
  39.       7.*) An comparison of configuration management systems (RCS, SCCS).
  40.  
  41. The following questions are answered:
  42.  
  43.       1.1)  Who helped you put this list together?
  44.       1.2)  When someone refers to 'rn(1)' or 'ctime(3)', what does
  45.               the number in parentheses mean?
  46.       1.3)  What does {some strange unix command name} stand for?
  47.       1.4)  How does the gateway between "comp.unix.questions" and the
  48.               "info-unix" mailing list work?
  49.       1.5)  What are some useful Unix or C books?
  50.       1.6)  What happened to the pronunciation list that used to be
  51.               part of this document?
  52.  
  53.       2.1)  How do I remove a file whose name begins with a "-" ?
  54.       2.2)  How do I remove a file with funny characters in the filename ?
  55.       2.3)  How do I get a recursive directory listing?
  56.       2.4)  How do I get the current directory into my prompt?
  57.       2.5)  How do I read characters from the terminal in a shell script?
  58.       2.6)  How do I rename "*.foo" to "*.bar", or change file names
  59.               to lowercase?
  60.       2.7)  Why do I get [some strange error message] when I
  61.               "rsh host command" ?
  62.       2.8)  How do I {set an environment variable, change directory} inside a
  63.               program or shell script and have that change affect my
  64.               current shell?
  65.       2.9)  How do I redirect stdout and stderr separately in csh?
  66.       2.10) How do I tell inside .cshrc if I'm a login shell?
  67.       2.11) How do I construct a shell glob-pattern that matches all files
  68.             except "." and ".." ?
  69.       2.12) How do I find the last argument in a Bourne shell script?
  70.       2.13) What's wrong with having '.' in your $PATH ?
  71.       2.14) How do I ring the terminal bell during a shell script?
  72.       2.15) Why can't I use "talk" to talk with my friend on machine X?
  73.       2.16) Why does calendar produce the wrong output?
  74.  
  75.       3.1)  How do I find the creation time of a file?
  76.       3.2)  How do I use "rsh" without having the rsh hang around
  77.               until the remote command has completed?
  78.       3.3)  How do I truncate a file?
  79.       3.4)  Why doesn't find's "{}" symbol do what I want?
  80.       3.5)  How do I set the permissions on a symbolic link?
  81.       3.6)  How do I "undelete" a file?
  82.       3.7)  How can a process detect if it's running in the background?
  83.       3.8)  Why doesn't redirecting a loop work as intended?  (Bourne shell)
  84.       3.9)  How do I run 'passwd', 'ftp', 'telnet', 'tip' and other interactive
  85.               programs from a shell script or in the background?
  86.       3.10) How do I find the process ID of a program with a particular
  87.             name from inside a shell script or C program?
  88.       3.11) How do I check the exit status of a remote command
  89.             executed via "rsh" ?
  90.       3.12) Is it possible to pass shell variable settings into an awk program?
  91.       3.13) How do I get rid of zombie processes that persevere?
  92.       3.14) How do I get lines from a pipe as they are written instead of
  93.             only in larger blocks.
  94.  
  95.       4.1)  How do I read characters from a terminal without requiring the user
  96.               to hit RETURN?
  97.       4.2)  How do I check to see if there are characters to be read without
  98.               actually reading?
  99.       4.3)  How do I find the name of an open file?
  100.       4.4)  How can an executing program determine its own pathname?
  101.       4.5)  How do I use popen() to open a process for reading AND writing?
  102.       4.6)  How do I sleep() in a C program for less than one second?
  103.       4.7)  How can I get setuid shell scripts to work?
  104.       4.8)  How can I find out which user or process has a file open or is using
  105.             a particular file system (so that I can unmount it?)
  106.       4.9)  How do I keep track of people who are fingering me?
  107.       4.10) Is it possible to reconnect a process to a terminal after it has
  108.             been disconnected, e.g. after starting a program in the background
  109.             and logging out?
  110.       4.11) Is it possible to "spy" on a terminal, displaying the output
  111.             that's appearing on it on another terminal?
  112.  
  113.       5.1)  Can shells be classified into categories?
  114.       5.2)  How do I "include" one shell script from within another
  115.             shell script?
  116.       5.3)  Do all shells have aliases?  Is there something else that
  117.             can be used?
  118.       5.4)  How are shell variables assigned?
  119.       5.5)  How can I tell if I am running an interactive shell?
  120.       5.6)  What "dot" files do the various shells use?
  121.       5.7)  I would like to know more about the differences between the
  122.             various shells.  Is this information available some place?
  123.  
  124.       6.1)  Disclaimer and introduction.
  125.       6.2)  A very brief look at Unix history.
  126.       6.3)  Main Unix flavors.
  127.       6.4)  Unix Standards.
  128.       6.5)  Identifying your Unix flavor.
  129.       6.6)  Brief notes on some well-known (commercial/PD) Unices.
  130.       6.7)  Real-time Unices.
  131.       6.8)  Unix glossary.
  132.       6.9)  Acknowledgements.
  133.  
  134.       7.1)  RCS vs SCCS:  Introduction
  135.       7.2)  RCS vs SCCS:  How do the interfaces compare?
  136.       7.3)  RCS vs SCCS:  What's in a Revision File?
  137.       7.4)  RCS vs SCCS:  What are the keywords?
  138.       7.5)  What's an RCS symbolic name?
  139.       7.6)  RCS vs SCCS:  How do they compare for performance?
  140.       7.7)  RCS vs SCCS:  Version Identification.
  141.       7.8)  RCS vs SCCS:  How do they handle with problems?
  142.       7.9)  RCS vs SCCS:  How do they interact with make(1)?
  143.       7.10) RCS vs SCCS:  Conversion.
  144.       7.11) RCS vs SCCS:  Support
  145.       7.12) RCS vs SCCS:  Command Comparison
  146.       7.13) RCS vs SCCS:  Acknowledgements
  147.       7.14) Can I get more information on configuration management systems?
  148.  
  149.       If you're looking for the answer to, say, question 2.5, look in
  150.       part 2 and search for the regular expression "^2.5)".
  151.  
  152. While these are all legitimate questions, they seem to crop up in
  153. comp.unix.questions or comp.unix.shell on an annual basis, usually
  154. followed by plenty of replies (only some of which are correct) and then
  155. a period of griping about how the same questions keep coming up.  You
  156. may also like to read the monthly article "Answers to Frequently Asked
  157. Questions" in the newsgroup "news.announce.newusers", which will tell
  158. you what "UNIX" stands for.
  159.  
  160. With the variety of Unix systems in the world, it's hard to guarantee
  161. that these answers will work everywhere.  Read your local manual pages
  162. before trying anything suggested here.  If you have suggestions or
  163. corrections for any of these answers, please send them to to
  164. tmatimar@isgtec.com.
  165.  
  166. -- 
  167. Ted Timar - tmatimar@isgtec.com
  168. ISG Technologies Inc., 6509 Airport Road, Mississauga, Ontario, Canada L4V 1S7
  169. Archive-name: unix-faq/faq/part1
  170. Version: $Id: part1,v 2.5 1994/04/28 19:25:03 tmatimar Exp tmatimar $
  171.  
  172. These seven articles contain the answers to some Frequently Asked
  173. Questions often seen in comp.unix.questions and comp.unix.shell.
  174. Please don't ask these questions again, they've been answered plenty
  175. of times already - and please don't flame someone just because they may
  176. not have read this particular posting.  Thank you.
  177.  
  178. This collection of documents is Copyright (c) 1994, Ted Timar, except
  179. Part 6, which is Copyright (c) 1994, Pierre Lewis and Ted Timar.
  180. All rights reserved.  Permission to distribute the collection is
  181. hereby granted providing that distribution is electronic, no money
  182. is involved, reasonable attempts are made to use the latest version
  183. and all credits and this copyright notice are maintained.
  184. Other requests for distribution will be considered.  All reasonable
  185. requests will be granted.
  186.  
  187. All information here has been contributed with good intentions, but
  188. none of it is guaranteed either by the contributors or myself to be
  189. accurate.  The users of this information take all responsibility for
  190. any damage that may occur.
  191.  
  192. Many FAQs, including this one, are available on the archive site
  193. rtfm.mit.edu in the directory pub/usenet/news.answers.
  194. The name under which a FAQ is archived appears in the "Archive-Name:"
  195. line at the top of the article.  This FAQ is archived as
  196. "unix-faq/faq/part[1-7]".
  197.  
  198. These articles are divided approximately as follows:
  199.  
  200.       1.*) General questions.
  201.       2.*) Relatively basic questions, likely to be asked by beginners.
  202.       3.*) Intermediate questions.
  203.       4.*) Advanced questions, likely to be asked by people who thought
  204.            they already knew all of the answers.
  205.       5.*) Questions pertaining to the various shells, and the differences.
  206.       6.*) An overview of Unix variants.
  207.       7.*) An comparison of configuration management systems (RCS, SCCS).
  208.  
  209. This article includes answers to:
  210.  
  211.       1.1)  Who helped you put this list together?
  212.       1.2)  When someone refers to 'rn(1)' or 'ctime(3)', what does
  213.               the number in parentheses mean?
  214.       1.3)  What does {some strange unix command name} stand for?
  215.       1.4)  How does the gateway between "comp.unix.questions" and the
  216.               "info-unix" mailing list work?
  217.       1.5)  What are some useful Unix or C books?
  218.       1.6)  What happened to the pronunciation list that used to be
  219.               part of this document?
  220.  
  221. If you're looking for the answer to, say, question 1.5, and want to skip
  222. everything else, you can search ahead for the regular expression "^1.5)".
  223.  
  224. While these are all legitimate questions, they seem to crop up in
  225. comp.unix.questions or comp.unix.shell on an annual basis, usually
  226. followed by plenty of replies (only some of which are correct) and then
  227. a period of griping about how the same questions keep coming up.  You
  228. may also like to read the monthly article "Answers to Frequently Asked
  229. Questions" in the newsgroup "news.announce.newusers", which will tell
  230. you what "UNIX" stands for.
  231.  
  232. With the variety of Unix systems in the world, it's hard to guarantee
  233. that these answers will work everywhere.  Read your local manual pages
  234. before trying anything suggested here.  If you have suggestions or
  235. corrections for any of these answers, please send them to to
  236. tmatimar@isgtec.com.
  237.  
  238. ----------------------------------------------------------------------
  239.  
  240. Subject: Who helped you put this list together?
  241. Date: Thu Mar 18 17:16:55 EST 1993
  242.  
  243. 1.1)  Who helped you put this list together?
  244.  
  245.       Happy Birthday Unix FAQ.  The Unix FAQ is now over 5 years old!
  246.       Everyone who ever contributed to this FAQ is encouraged to go out
  247.       and have a piece of birthday cake.  Unfortunately, I can't distribute
  248.       the cake by email, so you'll have to make your own.  :-)
  249.  
  250.       This document was one of the first collections of Frequently Asked
  251.       Questions.  It was originally compiled in July 1989.
  252.  
  253.       I took over the maintenance of this list.  Almost all of the work
  254.       (and the credit) for generating this compilation was done by
  255.       Steve Hayman.
  256.  
  257.       We also owe a great deal of thanks to dozens of Usenet readers who
  258.       submitted questions, answers, corrections and suggestions for this
  259.       list.  Special thanks go to Maarten Litmaath, Guy Harris and
  260.       Jonathan Kamens, who have all made many especially valuable
  261.       contributions.
  262.  
  263.       Part 5 of this document (shells) was written almost entirely by
  264.       Matthew Wicks <wicks@dcdmjw.fnal.gov>.
  265.  
  266.       Part 6 of this document (Unix flavours) was written almost entirely by
  267.       Pierre (P.) Lewis <lew@bnr.ca>.
  268.  
  269.       Where possible the author of each question and the date it was last
  270.       updated is given at the top.  Unfortunately, I only started this
  271.       practice recently, and much of the information is lost.  I was also
  272.       negligent in keeping track of who provided updates to questions.
  273.       Sorry to those who have made valuable contributions, but did not
  274.       receive the credit and recognition that they legitimately deserve.
  275.  
  276.       I make this document available in *roff format (ms and mm macro
  277.       packages).  Andrew Cromarty has also converted it into Texinfo format.
  278.  
  279. ------------------------------
  280.  
  281. Subject: When someone refers to 'rn(1)' ...  the number in parentheses mean?
  282. Date: Thu Mar 18 17:16:55 EST 1993
  283.  
  284. 1.2)  When someone refers to 'rn(1)' or 'ctime(3)', what does
  285.       the number in parentheses mean?
  286.  
  287.       It looks like some sort of function call, but it isn't.  These
  288.       numbers refer to the section of the "Unix manual" where the
  289.       appropriate documentation can be found.  You could type
  290.       "man 3 ctime" to look up the manual page for "ctime" in section 3
  291.       of the manual.
  292.  
  293.       The traditional manual sections are:
  294.  
  295.         1       User-level  commands
  296.         2       System calls
  297.         3       Library functions
  298.         4       Devices and device drivers
  299.         5       File formats
  300.         6       Games
  301.         7       Various miscellaneous stuff - macro packages etc.
  302.         8       System maintenance and operation commands
  303.  
  304.       Some Unix versions use non-numeric section names.  For instance,
  305.       Xenix uses "C" for commands and "S" for functions.  Some newer
  306.       versions of Unix require "man -s# title" instead of "man # title".
  307.  
  308.       Each section has an introduction, which you can read with "man #
  309.       intro" where # is the section number.
  310.  
  311.       Sometimes the number is necessary to differentiate between a
  312.       command and a library routine or system call of the same name.
  313.       For instance, your system may have "time(1)", a manual page about
  314.       the 'time' command for timing programs, and also "time(3)", a
  315.       manual page about the 'time' subroutine for determining the
  316.       current time.  You can use "man 1 time" or "man 3 time" to
  317.       specify which "time" man page you're interested in.
  318.  
  319.       You'll often find other sections for local programs or even
  320.       subsections of the sections above - Ultrix has sections 3m, 3n,
  321.       3x and 3yp among others.
  322.  
  323. ------------------------------
  324.  
  325. Subject: What does {some strange unix command name} stand for?
  326. Date: Thu Mar 18 17:16:55 EST 1993
  327.  
  328. 1.3)  What does {some strange unix command name} stand for?
  329.  
  330.       awk = "Aho Weinberger and Kernighan"
  331.  
  332.         This language was named by its authors, Al Aho, Peter
  333.         Weinberger and Brian Kernighan.
  334.  
  335.       grep = "Global Regular Expression Print"
  336.  
  337.         grep comes from the ed command to print all lines matching a
  338.         certain pattern
  339.  
  340.                     g/re/p
  341.  
  342.         where "re" is a "regular expression".
  343.  
  344.       fgrep = "Fixed GREP".
  345.  
  346.         fgrep searches for fixed strings only.  The "f" does not stand
  347.         for "fast" - in fact, "fgrep foobar *.c" is usually slower than
  348.         "egrep foobar *.c"  (Yes, this is kind of surprising. Try it.)
  349.  
  350.         Fgrep still has its uses though, and may be useful when searching
  351.         a file for a larger number of strings than egrep can handle.
  352.  
  353.       egrep = "Extended GREP"
  354.  
  355.         egrep uses fancier regular expressions than grep.  Many people
  356.         use egrep all the time, since it has some more sophisticated
  357.         internal algorithms than grep or fgrep, and is usually the
  358.         fastest of the three programs.
  359.  
  360.       cat = "CATenate"
  361.  
  362.         catenate is an obscure word meaning "to connect in a series",
  363.         which is what the "cat" command does to one or more files.  Not
  364.         to be confused with C/A/T, the Computer Aided Typesetter.
  365.  
  366.       gecos = "General Electric Comprehensive Operating System"
  367.         
  368.         When GE's large systems division was sold to Honeywell,
  369.         Honeywell dropped the "E" from "GECOS".
  370.  
  371.         Unix's password file has a "pw_gecos" field.  The name is a
  372.         real holdover from the early days.  Dennis Ritchie has reported:
  373.  
  374.             "Sometimes we sent printer output or batch jobs
  375.              to the GCOS machine.  The gcos field in the password file
  376.              was a place to stash the information for the $IDENT card.
  377.              Not elegant."
  378.  
  379.       nroff = "New ROFF"
  380.       troff = "Typesetter new ROFF"
  381.         
  382.         These are descendants of "roff", which was a re-implementation
  383.         of the Multics "runoff" program (a program that you'd use to
  384.         "run off" a good copy of a document).
  385.  
  386.       tee       = T
  387.  
  388.         From plumbing terminology for a T-shaped pipe splitter.
  389.  
  390.       bss = "Block Started by Symbol"
  391.         
  392.         Dennis Ritchie says:
  393.  
  394.             Actually the acronym (in the sense we took it up; it may
  395.             have other credible etymologies) is "Block Started by
  396.             Symbol." It was a pseudo-op in FAP (Fortran Assembly [-er?]
  397.             Program), an assembler for the IBM 704-709-7090-7094
  398.             machines.  It defined its label and set aside space for a
  399.             given number of words.  There was another pseudo-op, BES,
  400.             "Block Ended by Symbol" that did the same except that the
  401.             label was defined by the last assigned word + 1.  (On these
  402.             machines Fortran arrays were stored backwards in storage
  403.             and were 1-origin.)
  404.  
  405.             The usage is reasonably appropriate, because just as with
  406.             standard Unix loaders, the space assigned didn't have to be
  407.             punched literally into the object deck but was represented
  408.             by a count somewhere.
  409.  
  410.       biff = "BIFF"
  411.  
  412.         This command, which turns on asynchronous mail notification,
  413.         was actually named after a dog at Berkeley.
  414.  
  415.             I can confirm the origin of biff, if you're interested.
  416.             Biff was Heidi Stettner's dog, back when Heidi (and I, and
  417.             Bill Joy) were all grad students at U.C. Berkeley and the
  418.             early versions of BSD were being developed.   Biff was
  419.             popular among the residents of Evans Hall, and was known
  420.             for barking at the mailman, hence the name of the command.
  421.  
  422.         Confirmation courtesy of Eric Cooper, Carnegie Mellon University
  423.  
  424.       rc (as in ".cshrc" or "/etc/rc") = "RunCom"
  425.  
  426.         "rc" derives from "runcom", from the MIT CTSS system, ca. 1965.
  427.  
  428.             'There was a facility that would execute a bunch of
  429.             commands stored in a file; it was called "runcom" for "run
  430.             commands", and the file began to be called "a runcom."
  431.  
  432.             "rc" in Unix is a fossil from that usage.'
  433.         
  434.         Brian Kernighan & Dennis Ritchie, as told to Vicki Brown
  435.  
  436.         "rc" is also the name of the shell from the new Plan 9
  437.         operating system.
  438.  
  439.       Perl = "Practical Extraction and Report Language"
  440.       Perl = "Pathologically Eclectic Rubbish Lister"
  441.  
  442.         The Perl language is Larry Wall's highly popular
  443.         freely-available completely portable text, process, and file
  444.         manipulation tool that bridges the gap between shell and C
  445.         programming (or between doing it on the command line and
  446.         pulling your hair out).  For further information, see the
  447.         Usenet newsgroup comp.lang.perl.
  448.  
  449.       Don Libes' book "Life with Unix" contains lots more of these
  450.       tidbits.
  451.  
  452. ------------------------------
  453.  
  454. Subject: How does the gateway between "comp.unix.questions" ... work ?
  455. Date: Thu Mar 18 17:16:55 EST 1993
  456.  
  457. 1.4)  How does the gateway between "comp.unix.questions" and the
  458.       "info-unix" mailing list work?
  459.  
  460.       "info-unix" and "unix-wizards" are mailing list versions of
  461.       comp.unix.questions and comp.unix.wizards respectively.
  462.       There should be no difference in content between the
  463.       mailing list and the newsgroup.
  464.  
  465.       To get on or off either of these lists, send mail to
  466.       info-unix-request@brl.mil or unix-wizards-request@brl.mil.
  467.       Be sure to use the '-Request'.  Don't expect an immediate response.
  468.  
  469.       Here are the gory details, courtesy of the list's maintainer,
  470.       Bob Reschly.
  471.  
  472.       ==== postings to info-UNIX and UNIX-wizards lists ====
  473.  
  474.       Anything submitted to the list is posted; I do not moderate
  475.       incoming traffic -- BRL functions as a reflector.  Postings
  476.       submitted by Internet subscribers should be addressed to the list
  477.       address (info-UNIX or UNIX- wizards);  the '-request' addresses
  478.       are for correspondence with the list maintainer [me].  Postings
  479.       submitted by USENET readers should be addressed to the
  480.       appropriate news group (comp.unix.questions or
  481.       comp.unix.wizards).
  482.  
  483.       For Internet subscribers, received traffic will be of two types;
  484.       individual messages, and digests.  Traffic which comes to BRL
  485.       from the Internet and BITNET (via the BITNET-Internet gateway) is
  486.       immediately resent to all addressees on the mailing list.
  487.       Traffic originating on USENET is gathered up into digests which
  488.       are sent to all list members daily.
  489.  
  490.       BITNET traffic is much like Internet traffic.  The main
  491.       difference is that I maintain only one address for traffic
  492.       destined to all BITNET subscribers. That address points to a list
  493.       exploder which then sends copies to individual BITNET
  494.       subscribers.  This way only one copy of a given message has to
  495.       cross the BITNET-Internet gateway in either direction.
  496.  
  497.       USENET subscribers see only individual messages.  All messages
  498.       originating on the Internet side are forwarded to our USENET
  499.       machine.  They are then posted to the appropriate newsgroup.
  500.       Unfortunately, for gatewayed messages, the sender becomes
  501.       "news@brl-adm".  This is currently an unavoidable side-effect of
  502.       the software which performs the gateway function.
  503.  
  504.       As for readership, USENET has an extremely large readership - I
  505.       would guess several thousand hosts and tens of thousands of
  506.       readers.  The master list maintained here at BRL runs about two
  507.       hundred fifty entries with roughly ten percent of those being
  508.       local redistribution lists.  I don't have a good feel for the
  509.       size of the BITNET redistribution, but I would guess it is
  510.       roughly the same size and composition as the master list.
  511.       Traffic runs 150K to 400K bytes per list per week on average.
  512.  
  513. ------------------------------
  514.  
  515. Subject: What are some useful Unix or C books?
  516. Date: Thu Mar 18 17:16:55 EST 1993
  517.  
  518. 1.5)  What are some useful Unix or C books?
  519.  
  520.       Mitch Wright (mitch@cirrus.com) maintains a useful list of Unix
  521.       and C books, with descriptions and some mini-reviews.  There are
  522.       currently 167 titles on his list.
  523.  
  524.       You can obtain a copy of this list by anonymous ftp from
  525.       ftp.rahul.net (192.160.13.1), where it's "pub/mitch/YABL/yabl".
  526.       Send additions or suggestions to mitch@cirrus.com.
  527.  
  528.       Samuel Ko (kko@sfu.ca) maintains another list of Unix books.
  529.       This list contains only recommended books, and is therefore
  530.       somewhat shorter.  This list is also a classified list, with
  531.       books grouped into categories, which may be better if you are
  532.       looking for a specific type of book.
  533.  
  534.       You can obtain a copy of this list by anonymous ftp from
  535.       rtfm.mit.edu, where it's "pub/usenet/news.answers/books/unix".
  536.       Send additions or suggestions to kko@sfu.ca.
  537.  
  538.       If you can't use anonymous ftp, email the line "help" to
  539.       "ftpmail@decwrl.dec.com" for instructions on retrieving
  540.       things via email.
  541.  
  542. ------------------------------
  543.  
  544. Subject: What happened to the pronunciation list ... ?
  545. Date: Thu Mar 18 17:16:55 EST 1993
  546.  
  547. 1.6)  What happened to the pronunciation list that used to be part of this
  548.       document?
  549.  
  550.       From its inception in 1989, this FAQ document included a
  551.       comprehensive pronunciation list maintained by Maarten Litmaath
  552.       (thanks, Maarten!).  It was originally created by Carl Paukstis
  553.       <carlp@frigg.isc-br.com>.
  554.  
  555.       It has been retired, since it is not really relevant to the topic
  556.       of "Unix questions".  You can still find it as part of the
  557.       widely-distributed "Jargon" file (maintained by Eric S. Raymond,
  558.       eric@snark.thyrsus.com) which seems like a much more appropriate
  559.       forum for the topic of "How do you pronounce  /* ?"
  560.  
  561.       If you'd like a copy, you can ftp one from ftp.wg.omron.co.jp
  562.       (133.210.4.4), it's "pub/unix-faq/docs/Pronunciation-Guide".
  563.  
  564. ------------------------------
  565.  
  566. End of unix/faq Digest part 1 of 7
  567. **********************************
  568.  
  569. -- 
  570. Ted Timar - tmatimar@isgtec.com
  571. ISG Technologies Inc., 6509 Airport Road, Mississauga, Ontario, Canada L4V 1S7
  572. Archive-name: unix-faq/faq/part2
  573. Version: $Id: part2,v 2.5 1994/04/28 19:25:03 tmatimar Exp tmatimar $
  574.  
  575. These seven articles contain the answers to some Frequently Asked
  576. Questions often seen in comp.unix.questions and comp.unix.shell.
  577. Please don't ask these questions again, they've been answered plenty
  578. of times already - and please don't flame someone just because they may
  579. not have read this particular posting.  Thank you.
  580.  
  581. This collection of documents is Copyright (c) 1994, Ted Timar, except
  582. Part 6, which is Copyright (c) 1994, Pierre Lewis and Ted Timar.
  583. All rights reserved.  Permission to distribute the collection is
  584. hereby granted providing that distribution is electronic, no money
  585. is involved, reasonable attempts are made to use the latest version
  586. and all credits and this copyright notice are maintained.
  587. Other requests for distribution will be considered.  All reasonable
  588. requests will be granted.
  589.  
  590. All information here has been contributed with good intentions, but
  591. none of it is guaranteed either by the contributors or myself to be
  592. accurate.  The users of this information take all responsibility for
  593. any damage that may occur.
  594.  
  595. Many FAQs, including this one, are available on the archive site
  596. rtfm.mit.edu in the directory pub/usenet/news.answers.
  597. The name under which a FAQ is archived appears in the "Archive-Name:"
  598. line at the top of the article.  This FAQ is archived as
  599. "unix-faq/faq/part[1-7]".
  600.  
  601. These articles are divided approximately as follows:
  602.  
  603.       1.*) General questions.
  604.       2.*) Relatively basic questions, likely to be asked by beginners.
  605.       3.*) Intermediate questions.
  606.       4.*) Advanced questions, likely to be asked by people who thought
  607.              they already knew all of the answers.
  608.       5.*) Questions pertaining to the various shells, and the differences.
  609.       6.*) An overview of Unix variants.
  610.       7.*) An comparison of configuration management systems (RCS, SCCS).
  611.  
  612. This article includes answers to:
  613.  
  614.       2.1)  How do I remove a file whose name begins with a "-" ?
  615.       2.2)  How do I remove a file with funny characters in the filename ?
  616.       2.3)  How do I get a recursive directory listing?
  617.       2.4)  How do I get the current directory into my prompt?
  618.       2.5)  How do I read characters from the terminal in a shell script?
  619.       2.6)  How do I rename "*.foo" to "*.bar", or change file names
  620.               to lowercase?
  621.       2.7)  Why do I get [some strange error message] when I
  622.               "rsh host command" ?
  623.       2.8)  How do I {set an environment variable, change directory} inside a
  624.               program or shell script and have that change affect my
  625.               current shell?
  626.       2.9)  How do I redirect stdout and stderr separately in csh?
  627.       2.10) How do I tell inside .cshrc if I'm a login shell?
  628.       2.11) How do I construct a shell glob-pattern that matches all files
  629.             except "." and ".." ?
  630.       2.12) How do I find the last argument in a Bourne shell script?
  631.       2.13) What's wrong with having '.' in your $PATH ?
  632.       2.14) How do I ring the terminal bell during a shell script?
  633.       2.15) Why can't I use "talk" to talk with my friend on machine X?
  634.       2.16) Why does calendar produce the wrong output?
  635.  
  636. If you're looking for the answer to, say, question 2.5, and want to skip
  637. everything else, you can search ahead for the regular expression "^2.5)".
  638.  
  639. While these are all legitimate questions, they seem to crop up in
  640. comp.unix.questions or comp.unix.shell on an annual basis, usually
  641. followed by plenty of replies (only some of which are correct) and then
  642. a period of griping about how the same questions keep coming up.  You
  643. may also like to read the monthly article "Answers to Frequently Asked
  644. Questions" in the newsgroup "news.announce.newusers", which will tell
  645. you what "UNIX" stands for.
  646.  
  647. With the variety of Unix systems in the world, it's hard to guarantee
  648. that these answers will work everywhere.  Read your local manual pages
  649. before trying anything suggested here.  If you have suggestions or
  650. corrections for any of these answers, please send them to to
  651. tmatimar@isgtec.com.
  652.  
  653. ----------------------------------------------------------------------
  654.  
  655. Subject: How do I remove a file whose name begins with a "-" ?
  656. Date: Thu Mar 18 17:16:55 EST 1993
  657.  
  658. 2.1)  How do I remove a file whose name begins with a "-" ?
  659.  
  660.       Figure out some way to name the file so that it doesn't begin
  661.       with a dash.  The simplest answer is to use
  662.  
  663.             rm ./-filename
  664.  
  665.       (assuming "-filename" is in the current directory, of course.)
  666.       This method of avoiding the interpretation of the "-" works with
  667.       other commands too.
  668.  
  669.       Many commands, particularly those that have been written to use
  670.       the "getopt(3)" argument parsing routine, accept a "--" argument
  671.       which means "this is the last option, anything after this is not
  672.       an option", so your version of rm might handle "rm -- -filename".
  673.       Some versions of rm that don't use getopt() treat a single "-"
  674.       in the same way, so you can also try "rm - -filename".
  675.  
  676. ------------------------------
  677.  
  678. Subject: How do I remove a file with funny characters in the filename ?
  679. Date: Thu Mar 18 17:16:55 EST 1993
  680.  
  681. 2.2)  How do I remove a file with funny characters in the filename ?
  682.  
  683.       If the 'funny character' is a '/', skip to the last part of this
  684.       answer.  If the funny character is something else, such as a ' '
  685.       or control character or character with the 8th bit set, keep reading.
  686.  
  687.       The classic answers are
  688.  
  689.         rm -i some*pattern*that*matches*only*the*file*you*want
  690.  
  691.         which asks you whether you want to remove each file matching
  692.         the indicated pattern;  depending on your shell, this may not
  693.         work if the filename has a character with the 8th bit set (the
  694.         shell may strip that off);
  695.  
  696.       and
  697.  
  698.         rm -ri .
  699.  
  700.         which asks you whether to remove each file in the directory.
  701.         Answer "y" to the problem file and "n" to everything else.
  702.         Unfortunately this doesn't work with many versions of rm.  Also
  703.         unfortunately, this will walk through every subdirectory of ".",
  704.         so you might want to "chmod a-x" those directories temporarily
  705.         to make them unsearchable.
  706.  
  707.         Always take a deep breath and think about what you're doing and
  708.         double check what you typed when you use rm's "-r" flag or a
  709.         wildcard on the command line;
  710.  
  711.       and
  712.  
  713.         find . -type f ... -ok rm '{}' \;
  714.  
  715.       where "..." is a group of predicates that uniquely identify the
  716.       file.  One possibility is to figure out the inode number of the
  717.       problem file (use "ls -i .") and then use
  718.  
  719.         find . -inum 12345 -ok rm '{}' \;
  720.  
  721.       or
  722.         find . -inum 12345 -ok mv '{}' new-file-name \;
  723.         
  724.       "-ok" is a safety check - it will prompt you for confirmation of
  725.       the command it's about to execute.  You can use "-exec" instead
  726.       to avoid the prompting, if you want to live dangerously, or if
  727.       you suspect that the filename may contain a funny character
  728.       sequence that will mess up your screen when printed.
  729.  
  730.       What if the filename has a '/' in it?
  731.  
  732.       These files really are special cases, and can only be created by
  733.       buggy kernel code (typically by implementations of NFS that don't
  734.       filter out illegal characters in file names from remote
  735.       machines.)  The first thing to do is to try to understand exactly
  736.       why this problem is so strange.
  737.  
  738.       Recall that Unix directories are simply pairs of filenames and
  739.       inode numbers.  A directory essentially contains information
  740.       like this:
  741.  
  742.         filename  inode
  743.  
  744.         file1     12345
  745.         file2.c   12349
  746.         file3     12347
  747.  
  748.       Theoretically, '/' and '\0' are the only two characters that
  749.       cannot appear in a filename - '/' because it's used to separate
  750.       directories and files, and '\0' because it terminates a filename.
  751.  
  752.       Unfortunately some implementations of NFS will blithely create
  753.       filenames with embedded slashes in response to requests from
  754.       remote machines.  For instance, this could happen when someone on
  755.       a Mac or other non-Unix machine decides to create a remote NFS
  756.       file on your Unix machine with the date in the filename.  Your
  757.       Unix directory then has this in it:
  758.  
  759.         filename  inode
  760.  
  761.         91/02/07  12357
  762.  
  763.       No amount of messing around with 'find' or 'rm' as described
  764.       above will delete this file, since those utilities and all other
  765.       Unix programs, are forced to interpret the '/' in the normal way.
  766.  
  767.       Any ordinary program will eventually try to do
  768.       unlink("91/02/07"), which as far as the kernel is concerned means
  769.       "unlink the file 07 in the subdirectory 02 of directory 91", but
  770.       that's not what we have - we have a *FILE* named "91/02/07" in
  771.       the current directory.  This is a subtle but crucial distinction.
  772.  
  773.       What can you do in this case?  The first thing to try is to
  774.       return to the Mac that created this crummy entry, and see if you
  775.       can convince it and your local NFS daemon to rename the file to
  776.       something without slashes.
  777.  
  778.       If that doesn't work or isn't possible, you'll need help from
  779.       your system manager, who will have to try the one of the
  780.       following.  Use "ls -i" to find the inode number of this bogus
  781.       file, then unmount the file system and use "clri" to clear the
  782.       inode, and "fsck" the file system with your fingers crossed.
  783.       This destroys the information in the file.  If you want to keep
  784.       it, you can try:
  785.  
  786.         create a new directory in the same parent directory as the one
  787.         containing the bad file name;
  788.  
  789.         move everything you can (i.e. everything but the file with the
  790.         bad name) from the old directory to the new one;
  791.  
  792.         do "ls -id" on the directory containing the file with the bad
  793.         name to get its inumber;
  794.  
  795.         umount the file system;
  796.  
  797.         "clri" the directory containing the file with the bad name;
  798.  
  799.         "fsck" the file system.
  800.  
  801.       Then, to find the file,
  802.  
  803.         remount the file system;
  804.  
  805.         rename the directory you created to have the name of the old
  806.         directory (since the old directory should have been blown away
  807.         by "fsck")
  808.  
  809.         move the file out of "lost+found" into the directory with a
  810.         better name.
  811.  
  812.       Alternatively, you can patch the directory the hard way by
  813.       crawling around in the raw file system.  Use "fsdb", if you
  814.       have it.
  815.  
  816. ------------------------------
  817.  
  818. Subject: How do I get a recursive directory listing?
  819. Date: Thu Mar 18 17:16:55 EST 1993
  820.  
  821. 2.3)  How do I get a recursive directory listing?
  822.  
  823.       One of the following may do what you want:
  824.  
  825.         ls -R                   (not all versions of "ls" have -R)
  826.         find . -print           (should work everywhere)
  827.         du -a .                 (shows you both the name and size)
  828.  
  829.       If you're looking for a wildcard pattern that will match all ".c"
  830.       files in this directory and below, you won't find one, but you
  831.       can use
  832.  
  833.         % some-command `find . -name '*.c' -print`
  834.  
  835.       "find" is a powerful program.  Learn about it.
  836.  
  837. ------------------------------
  838.  
  839. Subject: How do I get the current directory into my prompt?
  840. Date: Thu Mar 18 17:16:55 EST 1993
  841.  
  842. 2.4)  How do I get the current directory into my prompt?
  843.  
  844.       It depends which shell you are using.  It's easy with some
  845.       shells, hard or impossible with others.
  846.  
  847.       C Shell (csh):
  848.         Put this in your .cshrc - customize the prompt variable the
  849.         way you want.
  850.  
  851.             alias setprompt 'set prompt="${cwd}% "'
  852.             setprompt           # to set the initial prompt
  853.             alias cd 'chdir \!* && setprompt'
  854.         
  855.         If you use pushd and popd, you'll also need
  856.  
  857.             alias pushd 'pushd \!* && setprompt'
  858.             alias popd  'popd  \!* && setprompt'
  859.  
  860.         Some C shells don't keep a $cwd variable - you can use
  861.         `pwd` instead.
  862.  
  863.         If you just want the last component of the current directory
  864.         in your prompt ("mail% " instead of "/usr/spool/mail% ")
  865.         you can use
  866.  
  867.             alias setprompt 'set prompt="$cwd:t% "'
  868.         
  869.         Some older csh's get the meaning of && and || reversed.
  870.         Try doing:
  871.  
  872.             false && echo bug
  873.  
  874.         If it prints "bug", you need to switch && and || (and get
  875.         a better version of csh.)
  876.  
  877.       Bourne Shell (sh):
  878.  
  879.         If you have a newer version of the Bourne Shell (SVR2 or newer)
  880.         you can use a shell function to make your own command, "xcd" say:
  881.  
  882.             xcd() { cd $* ; PS1="`pwd` $ "; }
  883.  
  884.         If you have an older Bourne shell, it's complicated but not
  885.         impossible.  Here's one way.  Add this to your .profile file:
  886.  
  887.                 LOGIN_SHELL=$$ export LOGIN_SHELL
  888.                 CMDFILE=/tmp/cd.$$ export CMDFILE
  889.                 # 16 is SIGURG, pick a signal that's not likely to be used
  890.                 PROMPTSIG=16 export PROMPTSIG
  891.                 trap '. $CMDFILE' $PROMPTSIG
  892.  
  893.         and then put this executable script (without the indentation!),
  894.         let's call it "xcd", somewhere in your PATH
  895.  
  896.                 : xcd directory - change directory and set prompt
  897.                 : by signalling the login shell to read a command file
  898.                 cat >${CMDFILE?"not set"} <<EOF
  899.                 cd $1
  900.                 PS1="\`pwd\`$ "
  901.                 EOF
  902.                 kill -${PROMPTSIG?"not set"} ${LOGIN_SHELL?"not set"}
  903.  
  904.         Now change directories with "xcd /some/dir".
  905.  
  906.       Korn Shell (ksh):
  907.  
  908.         Put this in your .profile file:
  909.                 PS1='$PWD $ '
  910.         
  911.         If you just want the last component of the directory, use
  912.                 PS1='${PWD##*/} $ '
  913.  
  914.       T C shell (tcsh)
  915.  
  916.         Tcsh is a popular enhanced version of csh with some extra
  917.         builtin variables (and many other features):
  918.  
  919.             %~          the current directory, using ~ for $HOME
  920.             %/          the full pathname of the current directory
  921.             %c or %.    the trailing component of the current directory
  922.  
  923.         so you can do
  924.  
  925.             set prompt='%~ '
  926.  
  927.       BASH (FSF's "Bourne Again SHell")
  928.         
  929.         \w in $PS1 gives the full pathname of the current directory,
  930.         with ~ expansion for $HOME;  \W gives the basename of
  931.         the current directory.  So, in addition to the above sh and
  932.         ksh solutions, you could use
  933.  
  934.             PS1='\w $ ' 
  935.         or
  936.             PS1='\W $ '
  937.  
  938. ------------------------------
  939.  
  940. Subject: How do I read characters from the terminal in a shell script?
  941. Date: Thu Mar 18 17:16:55 EST 1993
  942.  
  943. 2.5)  How do I read characters from the terminal in a shell script?
  944.  
  945.       In sh, use read.  It is most common to use a loop like
  946.  
  947.             while read line
  948.             do
  949.                     ...
  950.             done
  951.  
  952.       In csh, use $< like this:
  953.         
  954.             while ( 1 )
  955.                 set line = "$<"
  956.                 if ( "$line" == "" ) break
  957.                 ...
  958.             end
  959.  
  960.       Unfortunately csh has no way of distinguishing between a blank
  961.       line and an end-of-file.
  962.  
  963.       If you're using sh and want to read a *single* character from the
  964.       terminal, you can try something like
  965.  
  966.             echo -n "Enter a character: "
  967.             stty cbreak         # or  stty raw
  968.             readchar=`dd if=/dev/tty bs=1 count=1 2>/dev/null`
  969.             stty -cbreak
  970.  
  971.             echo "Thank you for typing a $readchar ."
  972.  
  973. ------------------------------
  974.  
  975. Subject: How do I rename "*.foo" to "*.bar", or change file names to lowercase?
  976. Date: Thu Mar 18 17:16:55 EST 1993
  977.  
  978. 2.6)  How do I rename "*.foo" to "*.bar", or change file names to lowercase?
  979.         
  980.       Why doesn't "mv *.foo *.bar" work?  Think about how the shell
  981.       expands wildcards.   "*.foo" and "*.bar" are expanded before the
  982.       mv command ever sees the arguments.  Depending on your shell,
  983.       this can fail in a couple of ways.  CSH prints "No match."
  984.       because it can't match "*.bar".  SH executes "mv a.foo b.foo
  985.       c.foo *.bar", which will only succeed if you happen to have a
  986.       single directory named "*.bar", which is very unlikely and almost
  987.       certainly not what you had in mind.
  988.  
  989.       Depending on your shell, you can do it with a loop to "mv" each
  990.       file individually.  If your system has "basename", you can use:
  991.  
  992.       C Shell:
  993.         foreach f ( *.foo )
  994.             set base=`basename $f .foo`
  995.             mv $f $base.bar
  996.         end
  997.  
  998.       Bourne Shell:
  999.         for f in *.foo; do
  1000.             base=`basename $f .foo`
  1001.             mv $f $base.bar
  1002.         done
  1003.  
  1004.       Some shells have their own variable substitution features, so
  1005.       instead of using "basename", you can use simpler loops like:
  1006.  
  1007.       C Shell:
  1008.  
  1009.         foreach f ( *.foo )
  1010.             mv $f $f:r.bar
  1011.         end
  1012.  
  1013.       Korn Shell:
  1014.  
  1015.         for f in *.foo; do
  1016.             mv $f ${f%foo}bar
  1017.         done
  1018.  
  1019.       If you don't have "basename" or want to do something like
  1020.       renaming foo.* to bar.*, you can use something like "sed" to
  1021.       strip apart the original file name in other ways, but the general
  1022.       looping idea is the same.  You can also convert file names into
  1023.       "mv" commands with 'sed', and hand the commands off to "sh" for
  1024.       execution.  Try
  1025.  
  1026.         ls -d *.foo | sed -e 's/.*/mv & &/' -e 's/foo$/bar/' | sh
  1027.  
  1028.       A program by Vladimir Lanin called "mmv" that does this job
  1029.       nicely was posted to comp.sources.unix (Volume 21, issues 87 and
  1030.       88) in April 1990.  It lets you use
  1031.  
  1032.         mmv '*.foo' '=1.bar'
  1033.  
  1034.       Shell loops like the above can also be used to translate file
  1035.       names from upper to lower case or vice versa.  You could use
  1036.       something like this to rename uppercase files to lowercase:
  1037.  
  1038.         C Shell:
  1039.             foreach f ( * )
  1040.                 mv $f `echo $f | tr '[A-Z]' '[a-z]'`
  1041.             end
  1042.         Bourne Shell:
  1043.             for f in *; do
  1044.                 mv $f `echo $f | tr '[A-Z]' '[a-z]'`
  1045.             done
  1046.         Korn Shell:
  1047.             typeset -l l
  1048.             for f in *; do
  1049.                 l="$f"
  1050.                 mv $f $l
  1051.             done
  1052.  
  1053.       If you wanted to be really thorough and handle files with `funny'
  1054.       names (embedded blanks or whatever) you'd need to use
  1055.  
  1056.         Bourne Shell:
  1057.  
  1058.             for f in *; do
  1059.               g=`expr "xxx$f" : 'xxx\(.*\)' | tr '[A-Z]' '[a-z]'`
  1060.               mv "$f" "$g"
  1061.             done
  1062.  
  1063.       The `expr' command will always print the filename, even if it
  1064.       equals `-n' or if it contains a System V escape sequence like `\c'.
  1065.  
  1066.       Some versions of "tr" require the [ and ], some don't.  It
  1067.       happens to be harmless to include them in this particular
  1068.       example; versions of tr that don't want the [] will conveniently
  1069.       think they are supposed to translate '[' to '[' and ']' to ']'.
  1070.  
  1071.       If you have the "perl" language installed, you may find this
  1072.       rename script by Larry Wall very useful.  It can be used to
  1073.       accomplish a wide variety of filename changes.
  1074.  
  1075.         #!/usr/bin/perl
  1076.         #
  1077.         # rename script examples from lwall:
  1078.         #       rename 's/\.orig$//' *.orig
  1079.         #       rename 'y/A-Z/a-z/ unless /^Make/' *
  1080.         #       rename '$_ .= ".bad"' *.f
  1081.         #       rename 'print "$_: "; s/foo/bar/ if <stdin> =~ /^y/i' *
  1082.  
  1083.         $op = shift;
  1084.         for (@ARGV) {
  1085.             $was = $_;
  1086.             eval $op;
  1087.             die $@ if $@;
  1088.             rename($was,$_) unless $was eq $_;
  1089.         }
  1090.  
  1091. ------------------------------
  1092.  
  1093. Subject: Why do I get [some strange error message] when I "rsh host command" ?
  1094. Date: Thu Mar 18 17:16:55 EST 1993
  1095.  
  1096. 2.7)  Why do I get [some strange error message] when I "rsh host command" ?
  1097.  
  1098.       (We're talking about the remote shell program "rsh" or sometimes
  1099.       "remsh" or "remote"; on some machines, there is a restricted shell
  1100.       called "rsh", which is a different thing.)
  1101.  
  1102.       If your remote account uses the C shell, the remote host will
  1103.       fire up a C shell to execute 'command' for you, and that shell
  1104.       will read your remote .cshrc file.  Perhaps your .cshrc contains
  1105.       a "stty", "biff" or some other command that isn't appropriate for
  1106.       a non-interactive shell.  The unexpected output or error message
  1107.       from these commands can screw up your rsh in odd ways.
  1108.  
  1109.       Here's an example.  Suppose you have
  1110.  
  1111.         stty erase ^H
  1112.         biff y
  1113.  
  1114.       in your .cshrc file.  You'll get some odd messages like this.
  1115.  
  1116.         % rsh some-machine date
  1117.         stty: : Can't assign requested address
  1118.         Where are you?
  1119.         Tue Oct  1 09:24:45 EST 1991
  1120.  
  1121.       You might also get similar errors when running certain "at" or
  1122.       "cron" jobs that also read your .cshrc file.
  1123.  
  1124.       Fortunately, the fix is simple.  There are, quite possibly, a
  1125.       whole *bunch* of operations in your ".cshrc" (e.g., "set
  1126.       history=N") that are simply not worth doing except in interactive
  1127.       shells.  What you do is surround them in your ".cshrc" with:
  1128.  
  1129.             if ( $?prompt ) then
  1130.                     operations....
  1131.             endif
  1132.  
  1133.       and, since in a non-interactive shell "prompt" won't be set, the
  1134.       operations in question will only be done in interactive shells.
  1135.  
  1136.       You may also wish to move some commands to your .login file; if
  1137.       those commands only need to be done when a login session starts
  1138.       up (checking for new mail, unread news and so on) it's better to
  1139.       have them in the .login file.
  1140.  
  1141. ------------------------------
  1142.  
  1143. Subject: How do I ... and have that change affect my current shell?
  1144. Date: Thu Mar 18 17:16:55 EST 1993
  1145.  
  1146. 2.8)  How do I {set an environment variable, change directory} inside
  1147.       a program or shell script and have that change affect my
  1148.       current shell?
  1149.  
  1150.       In general, you can't, at least not without making special
  1151.       arrangements.  When a child process is created, it inherits a
  1152.       copy of its parent's variables (and current directory).  The
  1153.       child can change these values all it wants but the changes won't
  1154.       affect the parent shell, since the child is changing a copy of
  1155.       the original data.
  1156.  
  1157.       Some special arrangements are possible.  Your child process could
  1158.       write out the changed variables, if the parent was prepared to
  1159.       read the output and interpret it as commands to set its own
  1160.       variables.
  1161.  
  1162.       Also, shells can arrange to run other shell scripts in the
  1163.       context of the current shell, rather than in a child process, so
  1164.       that changes will affect the original shell.
  1165.  
  1166.       For instance, if you have a C shell script named "myscript":
  1167.  
  1168.         cd /very/long/path
  1169.         setenv PATH /something:/something-else
  1170.  
  1171.       or the equivalent Bourne or Korn shell script
  1172.  
  1173.         cd /very/long/path
  1174.         PATH=/something:/something-else export PATH
  1175.  
  1176.       and try to run "myscript" from your shell, your shell will fork
  1177.       and run the shell script in a subprocess.  The subprocess is also
  1178.       running the shell; when it sees the "cd" command it changes *its*
  1179.       current directory, and when it sees the "setenv" command it
  1180.       changes *its* environment, but neither has any effect on the
  1181.       current directory of the shell at which you're typing (your login
  1182.       shell, let's say).
  1183.  
  1184.       In order to get your login shell to execute the script (without
  1185.       forking) you have to use the "." command (for the Bourne or Korn
  1186.       shells) or the "source" command (for the C shell).  I.e. you type
  1187.  
  1188.         . myscript
  1189.  
  1190.       to the Bourne or Korn shells, or
  1191.  
  1192.         source myscript
  1193.  
  1194.       to the C shell.
  1195.  
  1196.       If all you are trying to do is change directory or set an
  1197.       environment variable, it will probably be simpler to use a C
  1198.       shell alias or Bourne/Korn shell function.  See the "how do I get
  1199.       the current directory into my prompt" section of this article for
  1200.       some examples.
  1201.  
  1202.       A much more detailed answer prepared by
  1203.       xtm@telelogic.se (Thomas Michanek) can be found at
  1204.       ftp.wg.omron.co.jp in /pub/unix-faq/docs/script-vs-env.
  1205.  
  1206. ------------------------------
  1207.  
  1208. Subject: How do I redirect stdout and stderr separately in csh?
  1209. From: msb@sq.com (Mark Brader)
  1210. Date: Mon, 26 Oct 1992 20:15:00 -0500
  1211.  
  1212. 2.9)  How do I redirect stdout and stderr separately in csh?
  1213.  
  1214.       In csh, you can redirect stdout with ">", or stdout and stderr
  1215.       together with ">&" but there is no direct way to redirect stderr
  1216.       only.  The best you can do is
  1217.  
  1218.         ( command >stdout_file ) >&stderr_file
  1219.  
  1220.       which runs "command" in a subshell;  stdout is redirected inside
  1221.       the subshell to stdout_file, and both stdout and stderr from the
  1222.       subshell are redirected to stderr_file, but by this point stdout
  1223.       has already been redirected so only stderr actually winds up in
  1224.       stderr_file.
  1225.  
  1226.       If what you want is to avoid redirecting stdout at all, let sh
  1227.       do it for you.
  1228.  
  1229.         sh -c 'command 2>stderr_file'
  1230.  
  1231. ------------------------------
  1232.  
  1233. Subject: How do I tell inside .cshrc if I'm a login shell?
  1234. Date: Thu Mar 18 17:16:55 EST 1993
  1235.  
  1236. 2.10) How do I tell inside .cshrc if I'm a login shell?
  1237.  
  1238.       When people ask this, they usually mean either
  1239.  
  1240.         How can I tell if it's an interactive shell?  or
  1241.         How can I tell if it's a top-level shell?
  1242.  
  1243.       You could perhaps determine if your shell truly is a login shell
  1244.       (i.e. is going to source ".login" after it is done with ".cshrc")
  1245.       by fooling around with "ps" and "$$".  Login shells generally
  1246.       have names that begin with a '-'.  If you're really interested in
  1247.       the other two questions, here's one way you can organize your
  1248.       .cshrc to find out.
  1249.  
  1250.         if (! $?CSHLEVEL) then
  1251.                 #
  1252.                 # This is a "top-level" shell,
  1253.                 # perhaps a login shell, perhaps a shell started up by
  1254.                 # 'rsh machine some-command'
  1255.                 # This is where we should set PATH and anything else we
  1256.                 # want to apply to every one of our shells.
  1257.                 #
  1258.                 setenv      CSHLEVEL        0
  1259.                 set home = ~username        # just to be sure
  1260.                 source ~/.env               # environment stuff we always want
  1261.         else
  1262.                 #
  1263.                 # This shell is a child of one of our other shells so
  1264.                 # we don't need to set all the environment variables again.
  1265.                 #
  1266.                 set tmp = $CSHLEVEL
  1267.                 @ tmp++
  1268.                 setenv      CSHLEVEL        $tmp
  1269.         endif
  1270.  
  1271.         # Exit from .cshrc if not interactive, e.g. under rsh
  1272.         if (! $?prompt) exit
  1273.  
  1274.         # Here we could set the prompt or aliases that would be useful
  1275.         # for interactive shells only.
  1276.  
  1277.         source ~/.aliases
  1278.  
  1279. ------------------------------
  1280.  
  1281. Subject: How do I construct a ... matches all files except "." and ".." ?
  1282. Date: Thu Mar 18 17:16:55 EST 1993
  1283.  
  1284. 2.11) How do I construct a shell glob-pattern that matches all files
  1285.       except "." and ".." ?
  1286.  
  1287.       You'd think this would be easy.
  1288.  
  1289.       *        Matches all files that don't begin with a ".";
  1290.  
  1291.       .*             Matches all files that do begin with a ".", but
  1292.              this includes the special entries "." and "..",
  1293.              which often you don't want;
  1294.  
  1295.       .[!.]*   (Newer shells only; some shells use a "^" instead of
  1296.              the "!"; POSIX shells must accept the "!", but may
  1297.              accept a "^" as well; all portable applications shall
  1298.              not use an unquoted "^" immediately following the "[")
  1299.  
  1300.              Matches all files that begin with a "." and are
  1301.              followed by a non-"."; unfortunately this will miss
  1302.              "..foo";
  1303.  
  1304.       .??*     Matches files that begin with a "." and which are
  1305.              at least 3 characters long.  This neatly avoids
  1306.              "." and "..", but also misses ".a" .
  1307.  
  1308.       So to match all files except "." and ".." safely you have to use
  1309.       3 patterns (if you don't have filenames like ".a" you can leave
  1310.       out the first):
  1311.  
  1312.         .[!.]* .??* *
  1313.  
  1314.       Alternatively you could employ an external program or two and use
  1315.       backquote substitution.  This is pretty good:
  1316.  
  1317.       `ls -a | sed -e '/^\.$/d' -e '/^\.\.$/d'`
  1318.  
  1319.         (or `ls -A` in some Unix versions)
  1320.  
  1321.       but even it will mess up on files with newlines, IFS characters
  1322.       or wildcards in their names.
  1323.  
  1324. ------------------------------
  1325.  
  1326. Subject: How do I find the last argument in a Bourne shell script?
  1327. Date: Thu Mar 18 17:16:55 EST 1993
  1328.  
  1329. 2.12) How do I find the last argument in a Bourne shell script?
  1330.  
  1331.       Answer by:
  1332.         Martin Weitzel <@mikros.systemware.de:martin@mwtech.uucp>
  1333.         Maarten Litmaath <maart@nat.vu.nl>
  1334.  
  1335.       If you are sure the number of arguments is at most 9, you can use:
  1336.  
  1337.         eval last=\${$#}
  1338.  
  1339.       In POSIX-compatible shells it works for ANY number of arguments.
  1340.       The following works always too:
  1341.  
  1342.         for last
  1343.         do
  1344.                 :
  1345.         done
  1346.  
  1347.       This can be generalized as follows:
  1348.  
  1349.         for i
  1350.         do
  1351.                 third_last=$second_last
  1352.                 second_last=$last
  1353.                 last=$i
  1354.         done
  1355.  
  1356.       Now suppose you want to REMOVE the last argument from the list,
  1357.       or REVERSE the argument list, or ACCESS the N-th argument
  1358.       directly, whatever N may be.  Here is a basis of how to do it,
  1359.       using only built-in shell constructs, without creating subprocesses:
  1360.  
  1361.         t0= u0= rest='1 2 3 4 5 6 7 8 9' argv=
  1362.  
  1363.         for h in '' $rest
  1364.         do
  1365.                 for t in "$t0" $rest
  1366.                 do
  1367.                         for u in $u0 $rest
  1368.                         do
  1369.                                 case $# in
  1370.                                 0)
  1371.                                         break 3
  1372.                                 esac
  1373.                                 eval argv$h$t$u=\$1
  1374.                                 argv="$argv \"\$argv$h$t$u\""   # (1)
  1375.                                 shift
  1376.                         done
  1377.                         u0=0
  1378.                 done
  1379.                 t0=0
  1380.         done
  1381.  
  1382.         # now restore the arguments
  1383.         eval set x "$argv"                                      # (2)
  1384.         shift
  1385.  
  1386.       This example works for the first 999 arguments.  Enough?
  1387.       Take a good look at the lines marked (1) and (2) and convince
  1388.       yourself that the original arguments are restored indeed, no
  1389.       matter what funny characters they contain!
  1390.  
  1391.       To find the N-th argument now you can use this:
  1392.  
  1393.         eval argN=\$argv$N
  1394.  
  1395.       To reverse the arguments the line marked (1) must be changed to:
  1396.  
  1397.         argv="\"\$argv$h$t$u\" $argv"
  1398.  
  1399.       How to remove the last argument is left as an exercise.
  1400.  
  1401.       If you allow subprocesses as well, possibly executing nonbuilt-in
  1402.       commands, the `argvN' variables can be set up more easily:
  1403.  
  1404.         N=1
  1405.  
  1406.         for i
  1407.         do
  1408.                 eval argv$N=\$i
  1409.                 N=`expr $N + 1`
  1410.         done
  1411.  
  1412.       To reverse the arguments there is still a simpler method, that
  1413.       even does not create subprocesses.  This approach can also be
  1414.       taken if you want to delete e.g. the last argument, but in that
  1415.       case you cannot refer directly to the N-th argument any more,
  1416.       because the `argvN' variables are set up in reverse order:
  1417.  
  1418.         argv=
  1419.  
  1420.         for i
  1421.         do
  1422.                 eval argv$#=\$i
  1423.                 argv="\"\$argv$#\" $argv"
  1424.                 shift
  1425.         done
  1426.  
  1427.         eval set x "$argv"
  1428.         shift
  1429.  
  1430. ------------------------------
  1431.  
  1432. Subject: What's wrong with having '.' in your $PATH ?
  1433. Date: Thu Mar 18 17:16:55 EST 1993
  1434.  
  1435. 2.13) What's wrong with having '.' in your $PATH ?
  1436.  
  1437.       A bit of background: the PATH environment variable is a list of
  1438.       directories separated by colons.  When you type a command name
  1439.       without giving an explicit path (e.g. you type "ls", rather than
  1440.       "/bin/ls") your shell searches each directory in the PATH list in
  1441.       order, looking for an executable file by that name, and the shell
  1442.       will run the first matching program it finds.
  1443.  
  1444.       One of the directories in the PATH list can be the current
  1445.       directory "." .  It is also permissible to use an empty directory
  1446.       name in the PATH list to indicate the current directory.  Both of
  1447.       these are equivalent
  1448.  
  1449.       for csh users:
  1450.  
  1451.         setenv PATH :/usr/ucb:/bin:/usr/bin
  1452.         setenv PATH .:/usr/ucb:/bin:/usr/bin
  1453.  
  1454.       for sh or ksh users
  1455.  
  1456.         PATH=:/usr/ucb:/bin:/usr/bin export PATH
  1457.         PATH=.:/usr/ucb:/bin:/usr/bin export PATH
  1458.  
  1459.       Having "." somewhere in the PATH is convenient - you can type
  1460.       "a.out" instead of "./a.out" to run programs in the current
  1461.       directory.  But there's a catch.
  1462.  
  1463.       Consider what happens in the case  where "." is the first entry
  1464.       in the PATH.  Suppose your current directory is a publically-
  1465.       writable one, such as "/tmp".  If there just happens to be a
  1466.       program named "/tmp/ls" left there by some other user, and you
  1467.       type "ls" (intending, of course, to run the normal "/bin/ls"
  1468.       program), your shell will instead run "./ls", the other user's
  1469.       program.  Needless to say, the results of running an unknown
  1470.       program like this might surprise you.
  1471.  
  1472.       It's slightly better to have "." at the end of the PATH:
  1473.  
  1474.         setenv PATH /usr/ucb:/bin:/usr/bin:.
  1475.  
  1476.       Now if you're in /tmp and you type "ls", the shell will
  1477.       search /usr/ucb, /bin and /usr/bin for a program named
  1478.       "ls" before it gets around to looking in ".", and there
  1479.       is less risk of inadvertently running some other user's
  1480.       "ls" program.  This isn't 100% secure though - if you're
  1481.       a clumsy typist and some day type "sl -l" instead of "ls -l",
  1482.       you run the risk of running "./sl", if there is one.
  1483.       Some "clever" programmer could anticipate common typing
  1484.       mistakes and leave programs by those names scattered
  1485.       throughout public directories.  Beware.
  1486.  
  1487.       Many seasoned Unix users get by just fine without having
  1488.       "." in the PATH at all:
  1489.  
  1490.         setenv PATH /usr/ucb:/bin:/usr/bin
  1491.  
  1492.       If you do this, you'll need to type "./program" instead
  1493.       of "program" to run programs in the current directory, but
  1494.       the increase in security is probably worth it.
  1495.  
  1496. ------------------------------
  1497.  
  1498. Subject: How do I ring the terminal bell during a shell script?
  1499. From: uwe@mpi-sb.mpg.de (Uwe Waldmann)
  1500. Date: Fri, 30 Apr 93 16:33:00 +0200
  1501.  
  1502. 2.14) How do I ring the terminal bell during a shell script?
  1503.  
  1504.       The answer depends on your Unix version (or rather on the kind of
  1505.       "echo" program that is available on your machine).
  1506.  
  1507.       A BSD-like "echo" uses the "-n" option for suppressing the final
  1508.       newline and does not understand the octal \nnn notation.  Thus
  1509.       the command is
  1510.  
  1511.         echo -n '^G'
  1512.  
  1513.       where ^G means a _literal_ BEL-character (you can produce this in
  1514.       emacs using "Ctrl-Q Ctrl-G" and in vi using "Ctrl-V Ctrl-G").
  1515.  
  1516.       A SysV-like "echo" understands the \nnn notation and uses \c to
  1517.       suppress the final newline, so the answer is:
  1518.  
  1519.         echo '\007\c'
  1520.  
  1521. ------------------------------
  1522.  
  1523. Subject: Why can't I use "talk" to talk with my friend on machine X?
  1524. From: tmatimar@isgtec.com (Ted Timar)
  1525. Date: Thu Mar 18 17:16:55 EST 1993
  1526.  
  1527. 2.15) Why can't I use "talk" to talk with my friend on machine X?
  1528.  
  1529.       Unix has three common "talk" programs, none of which can talk with
  1530.       any of the others.  The "old" talk accounts for the first two types.
  1531.       This version (often called otalk) did not take "endian" order into
  1532.       account when talking to other machines.  As a consequence, the Vax
  1533.       version of otalk cannot talk with the Sun version of otalk.
  1534.       These versions of talk use port 517.
  1535.  
  1536.       Around 1987, most vendors (except Sun, who took 6 years longer than
  1537.       any of their competitors) standardized on a new talk (often called
  1538.       ntalk) which knows about network byte order.  This talk works between
  1539.       all machines that have it.  This version of talk uses port 518.
  1540.  
  1541.       There are now a few talk programs that speak both ntalk and one
  1542.       version of otalk.  The most common of these is called "ytalk".
  1543.  
  1544. ------------------------------
  1545.  
  1546. Subject: Why does calendar produce the wrong output?
  1547. From: tmatimar@isgtec.com (Ted Timar)
  1548. Date: Thu Sep  8 09:45:46 EDT 1994
  1549.  
  1550. 2.16) Why does calendar produce the wrong output?
  1551.  
  1552.       Frequently, people find that the output for the Unix calendar
  1553.       program, 'cal' produces output that they do not expect.
  1554.  
  1555.       The calendar for September 1752 is very odd:
  1556.  
  1557.                September 1752
  1558.              S  M Tu  W Th  F  S
  1559.                    1  2 14 15 16
  1560.             17 18 19 20 21 22 23
  1561.             24 25 26 27 28 29 30
  1562.  
  1563.       This is the month in which the US (the entire British Empire actually)
  1564.       switched from the Julian to the Gregorian calendar.
  1565.  
  1566.       The other common problem people have with the calendar program is
  1567.       that they pass it arguments like 'cal 9 94'.  This gives the calendar
  1568.       for September of AD 94, NOT 1994.
  1569.  
  1570. ------------------------------
  1571.  
  1572. End of unix/faq Digest part 2 of 7
  1573. **********************************
  1574.  
  1575. -- 
  1576. Ted Timar - tmatimar@isgtec.com
  1577. ISG Technologies Inc., 6509 Airport Road, Mississauga, Ontario, Canada L4V 1S7
  1578. Archive-name: unix-faq/faq/part3
  1579. Version: $Id: part3,v 2.5 1994/04/28 19:25:03 tmatimar Exp tmatimar $
  1580.  
  1581. These seven articles contain the answers to some Frequently Asked
  1582. Questions often seen in comp.unix.questions and comp.unix.shell.
  1583. Please don't ask these questions again, they've been answered plenty
  1584. of times already - and please don't flame someone just because they may
  1585. not have read this particular posting.  Thank you.
  1586.  
  1587. This collection of documents is Copyright (c) 1994, Ted Timar, except
  1588. Part 6, which is Copyright (c) 1994, Pierre Lewis and Ted Timar.
  1589. All rights reserved.  Permission to distribute the collection is
  1590. hereby granted providing that distribution is electronic, no money
  1591. is involved, reasonable attempts are made to use the latest version
  1592. and all credits and this copyright notice are maintained.
  1593. Other requests for distribution will be considered.  All reasonable
  1594. requests will be granted.
  1595.  
  1596. All information here has been contributed with good intentions, but
  1597. none of it is guaranteed either by the contributors or myself to be
  1598. accurate.  The users of this information take all responsibility for
  1599. any damage that may occur.
  1600.  
  1601. Many FAQs, including this one, are available on the archive site
  1602. rtfm.mit.edu in the directory pub/usenet/news.answers.
  1603. The name under which a FAQ is archived appears in the "Archive-Name:"
  1604. line at the top of the article.  This FAQ is archived as
  1605. "unix-faq/faq/part[1-7]".
  1606.  
  1607. These articles are divided approximately as follows:
  1608.  
  1609.       1.*) General questions.
  1610.       2.*) Relatively basic questions, likely to be asked by beginners.
  1611.       3.*) Intermediate questions.
  1612.       4.*) Advanced questions, likely to be asked by people who thought
  1613.            they already knew all of the answers.
  1614.       5.*) Questions pertaining to the various shells, and the differences.
  1615.       6.*) An overview of Unix variants.
  1616.       7.*) An comparison of configuration management systems (RCS, SCCS).
  1617.  
  1618. This article includes answers to:
  1619.  
  1620.       3.1)  How do I find the creation time of a file?
  1621.       3.2)  How do I use "rsh" without having the rsh hang around
  1622.               until the remote command has completed?
  1623.       3.3)  How do I truncate a file?
  1624.       3.4)  Why doesn't find's "{}" symbol do what I want?
  1625.       3.5)  How do I set the permissions on a symbolic link?
  1626.       3.6)  How do I "undelete" a file?
  1627.       3.7)  How can a process detect if it's running in the background?
  1628.       3.8)  Why doesn't redirecting a loop work as intended?  (Bourne shell)
  1629.       3.9)  How do I run 'passwd', 'ftp', 'telnet', 'tip' and other interactive
  1630.               programs from a shell script or in the background?
  1631.       3.10) How do I find the process ID of a program with a particular
  1632.             name from inside a shell script or C program?
  1633.       3.11) How do I check the exit status of a remote command
  1634.             executed via "rsh" ?
  1635.       3.12) Is it possible to pass shell variable settings into an awk program?
  1636.       3.13) How do I get rid of zombie processes that persevere?
  1637.       3.14) How do I get lines from a pipe as they are written instead of
  1638.             only in larger blocks.
  1639.  
  1640. If you're looking for the answer to, say, question 3.5, and want to skip
  1641. everything else, you can search ahead for the regular expression "^3.5)".
  1642.  
  1643. While these are all legitimate questions, they seem to crop up in
  1644. comp.unix.questions or comp.unix.shell on an annual basis, usually
  1645. followed by plenty of replies (only some of which are correct) and then
  1646. a period of griping about how the same questions keep coming up.  You
  1647. may also like to read the monthly article "Answers to Frequently Asked
  1648. Questions" in the newsgroup "news.announce.newusers", which will tell
  1649. you what "UNIX" stands for.
  1650.  
  1651. With the variety of Unix systems in the world, it's hard to guarantee
  1652. that these answers will work everywhere.  Read your local manual pages
  1653. before trying anything suggested here.  If you have suggestions or
  1654. corrections for any of these answers, please send them to to
  1655. tmatimar@isgtec.com.
  1656.  
  1657. ----------------------------------------------------------------------
  1658.  
  1659. Subject: How do I find the creation time of a file?
  1660. Date: Thu Mar 18 17:16:55 EST 1993
  1661.  
  1662. 3.1)  How do I find the creation time of a file?
  1663.  
  1664.       You can't - it isn't stored anywhere.  Files have a last-modified
  1665.       time (shown by "ls -l"), a last-accessed time (shown by "ls -lu")
  1666.       and an inode change time (shown by "ls -lc"). The latter is often
  1667.       referred to as the "creation time" - even in some man pages -
  1668.       but that's wrong; it's also set by such operations as mv, ln,
  1669.       chmod, chown and chgrp.
  1670.  
  1671.       The man page for "stat(2)" discusses this.
  1672.  
  1673. ------------------------------
  1674.  
  1675. Subject: How do I use "rsh" without having the rsh hang around ... ?
  1676. Date: Thu Mar 18 17:16:55 EST 1993
  1677.  
  1678. 3.2)  How do I use "rsh" without having the rsh hang around until the
  1679.       remote command has completed?
  1680.  
  1681.       (See note in question 2.7 about what "rsh" we're talking about.)
  1682.  
  1683.       The obvious answers fail:
  1684.             rsh machine command &
  1685.       or      rsh machine 'command &'
  1686.  
  1687.       For instance, try doing   rsh machine 'sleep 60 &' and you'll see
  1688.       that the 'rsh' won't exit right away.  It will wait 60 seconds
  1689.       until the remote 'sleep' command finishes, even though that
  1690.       command was started in the background on the remote machine.  So
  1691.       how do you get the 'rsh' to exit immediately after the 'sleep' is
  1692.       started?
  1693.  
  1694.       The solution - if you use csh on the remote machine:
  1695.  
  1696.             rsh machine -n 'command >&/dev/null </dev/null &'
  1697.  
  1698.       If you use sh on the remote machine:
  1699.  
  1700.             rsh machine -n 'command >/dev/null 2>&1 </dev/null &'
  1701.  
  1702.       Why?  "-n" attaches rsh's stdin to /dev/null so you could run the
  1703.       complete rsh command in the background on the LOCAL machine.
  1704.       Thus "-n" is equivalent to another specific "< /dev/null".
  1705.       Furthermore, the input/output redirections on the REMOTE machine
  1706.       (inside the single quotes) ensure that rsh thinks the session can
  1707.       be terminated (there's no data flow any more.)
  1708.  
  1709.       Note: The file that you redirect to/from on the remote machine
  1710.       doesn't have to be /dev/null; any ordinary file will do.
  1711.  
  1712.       In many cases, various parts of these complicated commands
  1713.       aren't necessary.
  1714.  
  1715. ------------------------------
  1716.  
  1717. Subject: How do I truncate a file?
  1718. Date: Thu Mar 18 17:16:55 EST 1993
  1719.  
  1720. 3.3)  How do I truncate a file?
  1721.  
  1722.       The BSD function ftruncate() sets the length of a file.  Xenix -
  1723.       and therefore SysV r3.2 and later - has the chsize() system
  1724.       call.  For other systems, the only kind of truncation you can do
  1725.       is truncation to length zero with creat() or open(..., O_TRUNC).
  1726.  
  1727. ------------------------------
  1728.  
  1729. Subject: Why doesn't find's "{}" symbol do what I want?
  1730. Date: Thu Mar 18 17:16:55 EST 1993
  1731.  
  1732. 3.4)  Why doesn't find's "{}" symbol do what I want?
  1733.  
  1734.       "find" has a -exec option that will execute a particular command
  1735.       on all the selected files. Find will replace any "{}" it sees
  1736.       with the name of the file currently under consideration.
  1737.  
  1738.       So, some day you might try to use "find" to run a command on
  1739.       every file, one directory at a time.  You might try this:
  1740.  
  1741.         find /path -type d -exec command {}/\* \;
  1742.  
  1743.       hoping that find will execute, in turn
  1744.  
  1745.         command directory1/*
  1746.         command directory2/*
  1747.         ...
  1748.  
  1749.       Unfortunately, find only expands the "{}" token when it appears
  1750.       by itself.  Find will leave anything else like "{}/*" alone, so
  1751.       instead of doing what you want, it will do
  1752.  
  1753.         command {}/*
  1754.         command {}/*
  1755.         ...
  1756.  
  1757.       once for each directory.  This might be a bug, it might be a
  1758.       feature, but we're stuck with the current behaviour.
  1759.  
  1760.       So how do you get around this?  One way would be to write a
  1761.       trivial little shell script, let's say "./doit", that consists of
  1762.  
  1763.         command "$1"/*
  1764.  
  1765.       You could then use
  1766.  
  1767.         find /path -type d -exec ./doit {} \;
  1768.  
  1769.       Or if you want to avoid the "./doit" shell script, you can use
  1770.  
  1771.         find /path -type d -exec sh -c 'command $0/*' {} \;
  1772.  
  1773.       (This works because within the 'command' of "sh -c 'command' A B C ...",
  1774.        $0 expands to A, $1 to B, and so on.)
  1775.  
  1776.       or you can use the construct-a-command-with-sed trick
  1777.  
  1778.         find /path -type d -print | sed 's:.*:command &/*:' | sh
  1779.  
  1780.       If all you're trying to do is cut down on the number of times
  1781.       that "command" is executed, you should see if your system has the
  1782.       "xargs" command.  Xargs reads arguments one line at a time from
  1783.       the standard input and assembles as many of them as will fit into
  1784.       one command line.  You could use
  1785.  
  1786.         find /path -print | xargs command
  1787.  
  1788.       which would result in one or more executions of
  1789.  
  1790.         command file1 file2 file3 file4 dir1/file1 dir1/file2
  1791.  
  1792.       Unfortunately this is not a perfectly robust or secure solution.
  1793.       Xargs expects its input lines to be terminated with newlines, so
  1794.       it will be confused by files with odd characters such as newlines
  1795.       in their names.
  1796.  
  1797. ------------------------------
  1798.  
  1799. Subject: How do I set the permissions on a symbolic link?
  1800. Date: Thu Mar 18 17:16:55 EST 1993
  1801.  
  1802. 3.5)  How do I set the permissions on a symbolic link?
  1803.  
  1804.       Permissions on a symbolic link don't really mean anything.  The
  1805.       only permissions that count are the permissions on the file that
  1806.       the link points to.
  1807.  
  1808. ------------------------------
  1809.  
  1810. Subject: How do I "undelete" a file?
  1811. Date: Thu Mar 18 17:16:55 EST 1993
  1812.  
  1813. 3.6)  How do I "undelete" a file?
  1814.  
  1815.       Someday, you are going to accidentally type something like
  1816.       "rm * .foo", and find you just deleted "*" instead of "*.foo".
  1817.       Consider it a rite of passage.
  1818.  
  1819.       Of course, any decent systems administrator should be doing
  1820.       regular backups.  Check with your sysadmin to see if a recent
  1821.       backup copy of your file is available.  But if it isn't, read
  1822.       on.
  1823.  
  1824.       For all intents and purposes, when you delete a file with "rm" it
  1825.       is gone.  Once you "rm" a file, the system totally forgets which
  1826.       blocks scattered around the disk were part of your file.  Even
  1827.       worse, the blocks from the file you just deleted are going to be
  1828.       the first ones taken and scribbled upon when the system needs
  1829.       more disk space.  However, never say never.  It is theoretically
  1830.       possible *if* you shut down the system immediately after the "rm"
  1831.       to recover portions of the data.  However, you had better have a
  1832.       very wizardly type person at hand with hours or days to spare to
  1833.       get it all back.
  1834.  
  1835.       Your first reaction when you "rm" a file by mistake is why not
  1836.       make a shell alias or procedure which changes "rm" to move files
  1837.       into a trash bin rather than delete them?  That way you can
  1838.       recover them if you make a mistake, and periodically clean out
  1839.       your trash bin.  Two points:  first, this is generally accepted
  1840.       as a *bad* idea.  You will become dependent upon this behaviour
  1841.       of "rm", and you will find yourself someday on a normal system
  1842.       where "rm" is really "rm", and you will get yourself in trouble.
  1843.       Second, you will eventually find that the hassle of dealing with
  1844.       the disk space and time involved in maintaining the trash bin, it
  1845.       might be easier just to be a bit more careful with "rm".  For
  1846.       starters, you should look up the "-i" option to "rm" in your
  1847.       manual.
  1848.  
  1849.       If you are still undaunted, then here is a possible simple
  1850.       answer.  You can create yourself a "can" command which moves
  1851.       files into a trashcan directory. In csh(1) you can place the
  1852.       following commands in the ".login" file in your home directory:
  1853.  
  1854.         alias can       'mv \!* ~/.trashcan'       # junk file(s) to trashcan
  1855.         alias mtcan     'rm -f ~/.trashcan/*'      # irretrievably empty trash
  1856.         if ( ! -d ~/.trashcan ) mkdir ~/.trashcan  # ensure trashcan exists
  1857.  
  1858.       You might also want to put a:
  1859.  
  1860.         rm -f ~/.trashcan/*
  1861.  
  1862.       in the ".logout" file in your home directory to automatically
  1863.       empty the trash when you log out.  (sh and ksh versions are left
  1864.       as an exercise for the reader.)
  1865.  
  1866.       MIT's Project Athena has produced a comprehensive
  1867.       delete/undelete/expunge/purge package, which can serve as a
  1868.       complete replacement for rm which allows file recovery.  This
  1869.       package was posted to comp.sources.misc (volume 17, issue
  1870.       023-026)
  1871.  
  1872. ------------------------------
  1873.  
  1874. Subject: How can a process detect if it's running in the background?
  1875. Date: Thu Mar 18 17:16:55 EST 1993
  1876.  
  1877. 3.7)  How can a process detect if it's running in the background?
  1878.  
  1879.       First of all: do you want to know if you're running in the
  1880.       background, or if you're running interactively? If you're
  1881.       deciding whether or not you should print prompts and the like,
  1882.       that's probably a better criterion. Check if standard input
  1883.       is a terminal:
  1884.  
  1885.             sh: if [ -t 0 ]; then ... fi
  1886.             C: if(isatty(0)) { ... }
  1887.  
  1888.       In general, you can't tell if you're running in the background.
  1889.       The fundamental problem is that different shells and different
  1890.       versions of UNIX have different notions of what "foreground" and
  1891.       "background" mean - and on the most common type of system with a
  1892.       better-defined notion of what they mean, programs can be moved
  1893.       arbitrarily between foreground and background!
  1894.  
  1895.       UNIX systems without job control typically put a process into the
  1896.       background by ignoring SIGINT and SIGQUIT and redirecting the
  1897.       standard input to "/dev/null"; this is done by the shell.
  1898.  
  1899.       Shells that support job control, on UNIX systems that support job
  1900.       control, put a process into the background by giving it a process
  1901.       group ID different from the process group to which the terminal
  1902.       belongs.  They move it back into the foreground by setting the
  1903.       terminal's process group ID to that of the process.  Shells that
  1904.       do *not* support job control, on UNIX systems that support job
  1905.       control, typically do what shells do on systems that don't
  1906.       support job control.
  1907.  
  1908. ------------------------------
  1909.  
  1910. Subject: Why doesn't redirecting a loop work as intended?  (Bourne shell)
  1911. Date: Thu Mar 18 17:16:55 EST 1993
  1912.  
  1913. 3.8)  Why doesn't redirecting a loop work as intended?  (Bourne shell)
  1914.  
  1915.       Take the following example:
  1916.  
  1917.         foo=bar
  1918.  
  1919.         while read line
  1920.         do
  1921.                 # do something with $line
  1922.                 foo=bletch
  1923.         done < /etc/passwd
  1924.  
  1925.         echo "foo is now: $foo"
  1926.  
  1927.       Despite the assignment ``foo=bletch'' this will print
  1928.       ``foo is now: bar'' in many implementations of the Bourne shell.
  1929.       Why?  Because of the following, often undocumented, feature of
  1930.       historic Bourne shells: redirecting a control structure (such as
  1931.       a loop, or an ``if'' statement) causes a subshell to be created,
  1932.       in which the structure is executed; variables set in that
  1933.       subshell (like the ``foo=bletch'' assignment) don't affect the
  1934.       current shell, of course.
  1935.  
  1936.       The POSIX 1003.2 Shell and Tools Interface standardization
  1937.       committee forbids the behaviour described above, i.e. in P1003.2
  1938.       conformant Bourne shells the example will print ``foo is now:
  1939.       bletch''.
  1940.  
  1941.       In historic (and P1003.2 conformant) implementations you can use
  1942.       the following `trick' to get around the redirection problem:
  1943.  
  1944.         foo=bar
  1945.  
  1946.         # make file descriptor 9 a duplicate of file descriptor 0 (stdin);
  1947.         # then connect stdin to /etc/passwd; the original stdin is now
  1948.         # `remembered' in file descriptor 9; see dup(2) and sh(1)
  1949.         exec 9<&0 < /etc/passwd
  1950.  
  1951.         while read line
  1952.         do
  1953.                 # do something with $line
  1954.                 foo=bletch
  1955.         done
  1956.  
  1957.         # make stdin a duplicate of file descriptor 9, i.e. reconnect
  1958.         # it to the original stdin; then close file descriptor 9
  1959.         exec 0<&9 9<&-
  1960.  
  1961.         echo "foo is now: $foo"
  1962.  
  1963.       This should always print ``foo is now: bletch''.
  1964.       Right, take the next example:
  1965.  
  1966.         foo=bar
  1967.  
  1968.         echo bletch | read foo
  1969.  
  1970.         echo "foo is now: $foo"
  1971.  
  1972.       This will print ``foo is now: bar'' in many implementations,
  1973.       ``foo is now: bletch'' in some others.  Why?  Generally each part
  1974.       of a pipeline is run in a different subshell; in some
  1975.       implementations though, the last command in the pipeline is made
  1976.       an exception: if it is a builtin command like ``read'', the
  1977.       current shell will execute it, else another subshell is created.
  1978.  
  1979.       POSIX 1003.2 allows both behaviours so portable scripts cannot
  1980.       depend on any of them.
  1981.  
  1982. ------------------------------
  1983.  
  1984. Subject: How do I run ... interactive programs from a shell script ... ?
  1985. Date: Thu Mar 18 17:16:55 EST 1993
  1986.  
  1987. 3.9)  How do I run 'passwd', 'ftp', 'telnet', 'tip' and other interactive
  1988.       programs from a shell script or in the background?
  1989.  
  1990.       These programs expect a terminal interface.  Shells makes no
  1991.       special provisions to provide one.  Hence, such programs cannot
  1992.       be automated in shell scripts.
  1993.  
  1994.       The 'expect' program provides a programmable terminal interface
  1995.       for automating interaction with such programs.  The following
  1996.       expect script is an example of a non-interactive version of
  1997.       passwd(1).
  1998.  
  1999.         # username is passed as 1st arg, password as 2nd
  2000.         set password [index $argv 2]
  2001.         spawn passwd [index $argv 1]
  2002.         expect "*password:"
  2003.         send "$password\r"
  2004.         expect "*password:"
  2005.         send "$password\r"
  2006.         expect eof
  2007.  
  2008.       expect can partially automate interaction which is especially
  2009.       useful for telnet, rlogin, debuggers or other programs that have
  2010.       no built-in command language.  The distribution provides an
  2011.       example script to rerun rogue until a good starting configuration
  2012.       appears.  Then, control is given back to the user to enjoy the game.
  2013.  
  2014.       Fortunately some programs have been written to manage the
  2015.       connection to a pseudo-tty so that you can run these sorts of
  2016.       programs in a script.
  2017.  
  2018.       To get expect, email "send pub/expect/expect.shar.Z" to
  2019.       library@cme.nist.gov or anonymous ftp same from
  2020.       ftp.cme.nist.gov.
  2021.  
  2022.       Another solution is provided by the pty 4.0 program, which runs a
  2023.       program under a pseudo-tty session and was posted to
  2024.       comp.sources.unix, volume 25.  A pty-based solution using named
  2025.       pipes to do the same as the above might look like this:
  2026.  
  2027.         #!/bin/sh
  2028.         /etc/mknod out.$$ p; exec 2>&1
  2029.         ( exec 4<out.$$; rm -f out.$$
  2030.         <&4 waitfor 'password:'
  2031.             echo "$2"
  2032.         <&4 waitfor 'password:'
  2033.             echo "$2"
  2034.         <&4 cat >/dev/null
  2035.         ) | ( pty passwd "$1" >out.$$ )
  2036.  
  2037.       Here, 'waitfor' is a simple C program that searches for
  2038.       its argument in the input, character by character.
  2039.  
  2040.       A simpler pty solution (which has the drawback of not
  2041.       synchronizing properly with the passwd program) is
  2042.  
  2043.         #!/bin/sh
  2044.         ( sleep 5; echo "$2"; sleep 5; echo "$2") | pty passwd "$1"
  2045.  
  2046. ------------------------------
  2047.  
  2048. Subject: How do I find the process ID of a program with a particular name ... ?
  2049. Date: Thu Mar 18 17:16:55 EST 1993
  2050.  
  2051. 3.10) How do I find the process ID of a program with a particular name
  2052.       from inside a shell script or C program?
  2053.  
  2054.       In a shell script:
  2055.  
  2056.       There is no utility specifically designed to map between program
  2057.       names and process IDs.  Furthermore, such mappings are often
  2058.       unreliable, since it's possible for more than one process to have
  2059.       the same name, and since it's possible for a process to change
  2060.       its name once it starts running.  However, a pipeline like this
  2061.       can often be used to get a list of processes (owned by you) with
  2062.       a particular name:
  2063.  
  2064.             ps ux | awk '/name/ && !/awk/ {print $2}'
  2065.  
  2066.       You replace "name" with the name of the process for which you are
  2067.       searching.
  2068.  
  2069.       The general idea is to parse the output of ps, using awk or grep
  2070.       or other utilities, to search for the lines with the specified
  2071.       name on them, and print the PID's for those lines.  Note that the
  2072.       "!/awk/" above prevents the awk process for being listed.
  2073.  
  2074.       You may have to change the arguments to ps, depending on what
  2075.       kind of Unix you are using.
  2076.  
  2077.       In a C program:
  2078.  
  2079.       Just as there is no utility specifically designed to map between
  2080.       program names and process IDs, there are no (portable) C library
  2081.       functions to do it either.
  2082.  
  2083.       However, some vendors provide functions for reading Kernel
  2084.       memory; for example, Sun provides the "kvm_" functions, and Data
  2085.       General provides the "dg_" functions.  It may be possible for any
  2086.       user to use these, or they may only be useable by the super-user
  2087.       (or a user in group "kmem") if read-access to kernel memory on
  2088.       your system is restricted.  Furthermore, these functions are
  2089.       often not documented or documented badly, and might change from
  2090.       release to release.
  2091.  
  2092.       Some vendors provide a "/proc" filesystem, which appears as a
  2093.       directory with a bunch of filenames in it.  Each filename is a
  2094.       number, corresponding to a process ID, and you can open the file
  2095.       and read it to get information about the process.  Once again,
  2096.       access to this may be restricted, and the interface to it may
  2097.       change from system to system.
  2098.  
  2099.       If you can't use vendor-specific library functions, and you
  2100.       don't have /proc, and you still want to do this completely
  2101.       in C, you
  2102.       are going to have to do the rummaging through kernel memory
  2103.       yourself.  For a good example of how to do this on many systems,
  2104.       see the sources to "ofiles", available in the comp.sources.unix
  2105.       archives.  (A package named "kstuff" to help with kernel
  2106.       rummaging was posted to alt.sources in May 1991 and is also
  2107.       available via anonymous ftp as
  2108.       usenet/alt.sources/articles/{329{6,7,8,9},330{0,1}}.Z from
  2109.       wuarchive.wustl.edu.)
  2110.  
  2111. ------------------------------
  2112.  
  2113. Subject: How do I check the exit status of a remote command executed via "rsh"?
  2114. Date: Thu Mar 18 17:16:55 EST 1993
  2115.  
  2116. 3.11) How do I check the exit status of a remote command
  2117.       executed via "rsh" ?
  2118.  
  2119.       This doesn't work:
  2120.  
  2121.         rsh some-machine some-crummy-command || echo "Command failed"
  2122.  
  2123.       The exit status of 'rsh' is 0 (success) if the rsh program
  2124.       itself completed successfully, which probably isn't what
  2125.       you wanted.
  2126.  
  2127.       If you want to check on the exit status of the remote program,
  2128.       you can try using Maarten Litmaath's 'ersh' script, which was
  2129.       posted to alt.sources in January, 1991.  ersh is a shell script
  2130.       that calls rsh, arranges for the remote machine to echo the
  2131.       status of the command after it completes, and exits with that
  2132.       status.
  2133.  
  2134. ------------------------------
  2135.  
  2136. Subject: Is it possible to pass shell variable settings into an awk program?
  2137. Date: Thu Mar 18 17:16:55 EST 1993
  2138.  
  2139. 3.12) Is it possible to pass shell variable settings into an awk program?
  2140.  
  2141.       There are two different ways to do this.  The first involves
  2142.       simply expanding the variable where it is needed in the program.
  2143.       For example, to get a list of all ttys you're using:
  2144.  
  2145.         who | awk '/^'"$USER"'/ { print $2 }'                           (1)
  2146.  
  2147.       Single quotes are usually used to enclose awk programs because
  2148.       the character '$' is often used in them, and '$' will be
  2149.       interpreted by the shell if enclosed inside double quotes, but
  2150.       not if enclosed inside single quotes.  In this case, we *want*
  2151.       the '$' in "$USER" to be interpreted by the shell, so we close
  2152.       the single quotes and then put the "$USER" inside double quotes.
  2153.       Note that there are no spaces in any of that, so the shell will
  2154.       see it all as one argument.  Note, further, that the double
  2155.       quotes probably aren't necessary in this particular case (i.e. we
  2156.       could have done
  2157.  
  2158.         who | awk '/^'$USER'/ { print $2 }'                             (2)
  2159.  
  2160.       ), but they should be included nevertheless because they are
  2161.       necessary when the shell variable in question contains special
  2162.       characters or spaces.
  2163.  
  2164.       The second way to pass variable settings into awk is to use an
  2165.       often undocumented feature of awk which allows variable settings
  2166.       to be specified as "fake file names" on the command line.  For
  2167.       example:
  2168.  
  2169.         who | awk '$1 == user { print $2 }' user="$USER" -              (3)
  2170.  
  2171.       Variable settings take effect when they are encountered on the
  2172.       command line, so, for example, you could instruct awk on how to
  2173.       behave for different files using this technique.  For example:
  2174.  
  2175.         awk '{ program that depends on s }' s=1 file1 s=0 file2         (4)
  2176.  
  2177.       Note that some versions of awk will cause variable settings
  2178.       encountered before any real filenames to take effect before the
  2179.       BEGIN block is executed, but some won't so neither way should be
  2180.       relied upon.
  2181.  
  2182.       Note, further, that when you specify a variable setting, awk
  2183.       won't automatically read from stdin if no real files are
  2184.       specified, so you need to add a "-" argument to the end of your
  2185.       command, as I did at (3) above.
  2186.  
  2187. ------------------------------
  2188.  
  2189. Subject: How do I get rid of zombie processes that persevere?
  2190. From: jik@rtfm.MIT.Edu (Jonathan I. Kamens)
  2191. From: casper@fwi.uva.nl (Casper Dik)
  2192. Date: Thu, 09 Sep 93 16:39:58 +0200
  2193.  
  2194. 3.13) How do I get rid of zombie processes that persevere?
  2195.  
  2196.       Unfortunately, it's impossible to generalize how the death of
  2197.       child processes should behave, because the exact mechanism varies
  2198.       over the various flavors of Unix.
  2199.  
  2200.       First of all, by default, you have to do a wait() for child
  2201.       processes under ALL flavors of Unix.  That is, there is no flavor
  2202.       of Unix that I know of that will automatically flush child
  2203.       processes that exit, even if you don't do anything to tell it to
  2204.       do so.
  2205.  
  2206.       Second, under some SysV-derived systems, if you do
  2207.       "signal(SIGCHLD, SIG_IGN)" (well, actually, it may be SIGCLD
  2208.       instead of SIGCHLD, but most of the newer SysV systems have
  2209.       "#define SIGCHLD SIGCLD" in the header files), then child
  2210.       processes will be cleaned up automatically, with no further
  2211.       effort in your part.  The best way to find out if it works at
  2212.       your site is to try it, although if you are trying to write
  2213.       portable code, it's a bad idea to rely on this in any case.
  2214.       Unfortunately, POSIX doesn't allow you to do this; the behavior
  2215.       of setting the SIGCHLD to SIG_IGN under POSIX is undefined, so
  2216.       you can't do it if your program is supposed to be
  2217.       POSIX-compliant.
  2218.  
  2219.       So, what's the POSIX way? As mentioned earlier, you must
  2220.       install a signal handler and wait. Under POSIX signal handlers
  2221.       are installed with sigaction. Since you are not interested in
  2222.       ``stopped'' children, only in terminated children, add SA_NOCLDSTOP
  2223.       to sa_flags.  Waiting without blocking is done with waitpid().
  2224.       The first argument to waitpid should be -1 (wait for any pid),
  2225.       the third should be WNOHANG. This is the most portable way
  2226.       and is likely to become more portable in future.
  2227.  
  2228.       If your systems doesn't support POSIX, there's a number of ways.
  2229.       The easiest way is signal(SIGCHLD, SIG_IGN), if it works.
  2230.       If SIG_IGN cannot be used to force automatic clean-up, then you've
  2231.       got to write a signal handler to do it.  It isn't easy at all to
  2232.       write a signal handler that does things right on all flavors of
  2233.       Unix, because of the following inconsistencies:
  2234.  
  2235.       On some flavors of Unix, the SIGCHLD signal handler is called if
  2236.       one *or more* children have died.  This means that if your signal
  2237.       handler only does one wait() call, then it won't clean up all of
  2238.       the children.  Fortunately, I believe that all Unix flavors for
  2239.       which this is the case have available to the programmer the
  2240.       wait3() or waitpid() call, which allows the WNOHANG option to
  2241.       check whether or not there are any children waiting to be cleaned
  2242.       up.  Therefore, on any system that has wait3()/waitpid(), your
  2243.       signal handler should call wait3()/waitpid() over and over again
  2244.       with the WNOHANG option until there are no children left to clean
  2245.       up. Waitpid() is the preferred interface, as it is in POSIX.
  2246.  
  2247.       On SysV-derived systems, SIGCHLD signals are regenerated if there
  2248.       are child processes still waiting to be cleaned up after you exit
  2249.       the SIGCHLD signal handler.  Therefore, it's safe on most SysV
  2250.       systems to assume when the signal handler gets called that you
  2251.       only have to clean up one signal, and assume that the handler
  2252.       will get called again if there are more to clean up after it
  2253.       exits.
  2254.  
  2255.       On older systems, there is no way to prevent signal handlers
  2256.       from being automatically reset to SIG_DFL when the signal
  2257.       handler gets called.  On such systems, you have to put
  2258.       "signal(SIGCHILD, catcher_func)" (where "catcher_func" is the
  2259.       name of the handler function) as the last thing in the signal
  2260.       handler, so that it gets reset.
  2261.  
  2262.       Fortunately, newer implementations allow signal handlers to be
  2263.       installed without being reset to SIG_DFL when the handler
  2264.       function is called.  To get around this problem, on systems that
  2265.       do not have wait3()/waitpid() but do have SIGCLD, you need to
  2266.       reset the signal handler with a call to signal() after doing at
  2267.       least one wait() within the handler, each time it is called.  For
  2268.       backward compatibility reasons, System V will keep the old
  2269.       semantics (reset handler on call) of signal().  Signal handlers
  2270.       that stick can be installed with sigaction() or sigset().
  2271.  
  2272.       The summary of all this is that on systems that have waitpid()
  2273.       (POSIX) or wait3(), you should use that and your signal handler
  2274.       should loop, and on systems that don't, you should have one call
  2275.       to wait() per invocation of the signal handler.
  2276.  
  2277.       One more thing -- if you don't want to go through all of this
  2278.       trouble, there is a portable way to avoid this problem, although
  2279.       it is somewhat less efficient.  Your parent process should fork,
  2280.       and then wait right there and then for the child process to
  2281.       terminate.  The child process then forks again, giving you a
  2282.       child and a grandchild.  The child exits immediately (and hence
  2283.       the parent waiting for it notices its death and continues to
  2284.       work), and the grandchild does whatever the child was originally
  2285.       supposed to.  Since its parent died, it is inherited by init,
  2286.       which will do whatever waiting is needed.  This method is
  2287.       inefficient because it requires an extra fork, but is pretty much
  2288.       completely portable.
  2289.  
  2290. ------------------------------
  2291.  
  2292. Subject: How do I get lines from a pipe ... instead of only in larger blocks?
  2293. From: jik@rtfm.MIT.Edu (Jonathan I. Kamens)
  2294. Date: Sun, 16 Feb 92 20:59:28 -0500
  2295.  
  2296. 3.14) How do I get lines from a pipe as they are written instead of only in
  2297.       larger blocks?
  2298.  
  2299.       The stdio library does buffering differently depending on whether
  2300.       it thinks it's running on a tty.  If it thinks it's on a tty, it
  2301.       does buffering on a per-line basis; if not, it uses a larger
  2302.       buffer than one line.
  2303.  
  2304.       If you have the source code to the client whose buffering you
  2305.       want to disable, you can use setbuf() or setvbuf() to change the
  2306.       buffering.
  2307.  
  2308.       If not, the best you can do is try to convince the program that
  2309.       it's running on a tty by running it under a pty, e.g. by using
  2310.       the "pty" program mentioned in question 3.9.
  2311.  
  2312. ------------------------------
  2313.  
  2314. End of unix/faq Digest part 3 of 7
  2315. **********************************
  2316.  
  2317. -- 
  2318. Ted Timar - tmatimar@isgtec.com
  2319. ISG Technologies Inc., 6509 Airport Road, Mississauga, Ontario, Canada L4V 1S7
  2320. Archive-name: unix-faq/faq/part4
  2321. Version: $Id: part4,v 2.5 1994/04/28 19:25:03 tmatimar Exp tmatimar $
  2322.  
  2323. These seven articles contain the answers to some Frequently Asked
  2324. Questions often seen in comp.unix.questions and comp.unix.shell.
  2325. Please don't ask these questions again, they've been answered plenty
  2326. of times already - and please don't flame someone just because they may
  2327. not have read this particular posting.  Thank you.
  2328.  
  2329. This collection of documents is Copyright (c) 1994, Ted Timar, except
  2330. Part 6, which is Copyright (c) 1994, Pierre Lewis and Ted Timar.
  2331. All rights reserved.  Permission to distribute the collection is
  2332. hereby granted providing that distribution is electronic, no money
  2333. is involved, reasonable attempts are made to use the latest version
  2334. and all credits and this copyright notice are maintained.
  2335. Other requests for distribution will be considered.  All reasonable
  2336. requests will be granted.
  2337.  
  2338. All information here has been contributed with good intentions, but
  2339. none of it is guaranteed either by the contributors or myself to be
  2340. accurate.  The users of this information take all responsibility for
  2341. any damage that may occur.
  2342.  
  2343. Many FAQs, including this one, are available on the archive site
  2344. rtfm.mit.edu in the directory pub/usenet/news.answers.
  2345. The name under which a FAQ is archived appears in the "Archive-Name:"
  2346. line at the top of the article.  This FAQ is archived as
  2347. "unix-faq/faq/part[1-7]".
  2348.  
  2349. These articles are divided approximately as follows:
  2350.  
  2351.       1.*) General questions.
  2352.       2.*) Relatively basic questions, likely to be asked by beginners.
  2353.       3.*) Intermediate questions.
  2354.       4.*) Advanced questions, likely to be asked by people who thought
  2355.            they already knew all of the answers.
  2356.       5.*) Questions pertaining to the various shells, and the differences.
  2357.       6.*) An overview of Unix variants.
  2358.       7.*) An comparison of configuration management systems (RCS, SCCS).
  2359.  
  2360. This article includes answers to:
  2361.  
  2362.       4.1)  How do I read characters from a terminal without requiring the user
  2363.               to hit RETURN?
  2364.       4.2)  How do I check to see if there are characters to be read without
  2365.               actually reading?
  2366.       4.3)  How do I find the name of an open file?
  2367.       4.4)  How can an executing program determine its own pathname?
  2368.       4.5)  How do I use popen() to open a process for reading AND writing?
  2369.       4.6)  How do I sleep() in a C program for less than one second?
  2370.       4.7)  How can I get setuid shell scripts to work?
  2371.       4.8)  How can I find out which user or process has a file open or is using
  2372.             a particular file system (so that I can unmount it?)
  2373.       4.9)  How do I keep track of people who are fingering me?
  2374.       4.10) Is it possible to reconnect a process to a terminal after it has
  2375.             been disconnected, e.g. after starting a program in the background
  2376.             and logging out?
  2377.       4.11) Is it possible to "spy" on a terminal, displaying the output
  2378.             that's appearing on it on another terminal?
  2379.  
  2380. If you're looking for the answer to, say, question 4.5, and want to skip
  2381. everything else, you can search ahead for the regular expression "^4.5)".
  2382.  
  2383. While these are all legitimate questions, they seem to crop up in
  2384. comp.unix.questions or comp.unix.shell on an annual basis, usually
  2385. followed by plenty of replies (only some of which are correct) and then
  2386. a period of griping about how the same questions keep coming up.  You
  2387. may also like to read the monthly article "Answers to Frequently Asked
  2388. Questions" in the newsgroup "news.announce.newusers", which will tell
  2389. you what "UNIX" stands for.
  2390.  
  2391. With the variety of Unix systems in the world, it's hard to guarantee
  2392. that these answers will work everywhere.  Read your local manual pages
  2393. before trying anything suggested here.  If you have suggestions or
  2394. corrections for any of these answers, please send them to to
  2395. tmatimar@isgtec.com.
  2396.  
  2397. ----------------------------------------------------------------------
  2398.  
  2399. Subject: How do I read characters ... without requiring the user to hit RETURN?
  2400. Date: Thu Mar 18 17:16:55 EST 1993
  2401.  
  2402. 4.1)  How do I read characters from a terminal without requiring the user
  2403.       to hit RETURN?
  2404.  
  2405.       Check out cbreak mode in BSD, ~ICANON mode in SysV.
  2406.  
  2407.       If you don't want to tackle setting the terminal parameters
  2408.       yourself (using the "ioctl(2)" system call) you can let the stty
  2409.       program do the work - but this is slow and inefficient, and you
  2410.       should change the code to do it right some time:
  2411.  
  2412.       #include <stdio.h>
  2413.       main()
  2414.       {
  2415.             int c;
  2416.  
  2417.             printf("Hit any character to continue\n");
  2418.             /*
  2419.              * ioctl() would be better here; only lazy
  2420.              * programmers do it this way:
  2421.              */
  2422.             system("/bin/stty cbreak");        /* or "stty raw" */
  2423.             c = getchar();
  2424.             system("/bin/stty -cbreak");
  2425.             printf("Thank you for typing %c.\n", c);
  2426.  
  2427.             exit(0);
  2428.       }
  2429.  
  2430.       Several people have sent me various more correct solutions to
  2431.       this problem.  I'm sorry that I'm not including any of them here,
  2432.       because they really are beyond the scope of this list.
  2433.  
  2434.       You might like to check out the documentation for the "curses"
  2435.       library of portable screen functions.  Often if you're interested
  2436.       in single-character I/O like this, you're also interested in
  2437.       doing some sort of screen display control, and the curses library
  2438.       provides various portable routines for both functions.
  2439.  
  2440. ------------------------------
  2441.  
  2442. Subject: How do I check to see if there are characters to be read ... ?
  2443. Date: Thu Mar 18 17:16:55 EST 1993
  2444.  
  2445. 4.2)  How do I check to see if there are characters to be read without
  2446.       actually reading?
  2447.  
  2448.       Certain versions of UNIX provide ways to check whether characters
  2449.       are currently available to be read from a file descriptor.  In
  2450.       BSD, you can use select(2).  You can also use the FIONREAD ioctl
  2451.       (see tty(4)), which returns the number of characters waiting to
  2452.       be read, but only works on terminals, pipes and sockets.  In
  2453.       System V Release 3, you can use poll(2), but that only works on
  2454.       streams.  In Xenix - and therefore Unix SysV r3.2 and later - the
  2455.       rdchk() system call reports whether a read() call on a given file
  2456.       descriptor will block.
  2457.  
  2458.       There is no way to check whether characters are available to be
  2459.       read from a FILE pointer.  (You could poke around inside stdio
  2460.       data structures to see if the input buffer is nonempty, but that
  2461.       wouldn't work since you'd have no way of knowing what will happen
  2462.       the next time you try to fill the buffer.)
  2463.  
  2464.       Sometimes people ask this question with the intention of writing
  2465.             if (characters available from fd)
  2466.                     read(fd, buf, sizeof buf);
  2467.       in order to get the effect of a nonblocking read.  This is not
  2468.       the best way to do this, because it is possible that characters
  2469.       will be available when you test for availability, but will no
  2470.       longer be available when you call read.  Instead, set the
  2471.       O_NDELAY flag (which is also called FNDELAY under BSD) using the
  2472.       F_SETFL option of fcntl(2).  Older systems (Version 7, 4.1 BSD)
  2473.       don't have O_NDELAY; on these systems the closest you can get to
  2474.       a nonblocking read is to use alarm(2) to time out the read.
  2475.  
  2476. ------------------------------
  2477.  
  2478. Subject: How do I find the name of an open file?
  2479. Date: Thu Mar 18 17:16:55 EST 1993
  2480.  
  2481. 4.3)  How do I find the name of an open file?
  2482.  
  2483.       In general, this is too difficult.  The file descriptor may
  2484.       be attached to a pipe or pty, in which case it has no name.
  2485.       It may be attached to a file that has been removed.  It may
  2486.       have multiple names, due to either hard or symbolic links.
  2487.  
  2488.       If you really need to do this, and be sure you think long
  2489.       and hard about it and have decided that you have no choice,
  2490.       you can use find with the -inum and possibly -xdev option,
  2491.       or you can use ncheck, or you can recreate the functionality
  2492.       of one of these within your program.  Just realize that
  2493.       searching a 600 megabyte filesystem for a file that may not
  2494.       even exist is going to take some time.
  2495.  
  2496. ------------------------------
  2497.  
  2498. Subject: How can an executing program determine its own pathname?
  2499. Date: Thu Mar 18 17:16:55 EST 1993
  2500.  
  2501. 4.4)  How can an executing program determine its own pathname?
  2502.  
  2503.       Your program can look at argv[0]; if it begins with a "/", it is
  2504.       probably the absolute pathname to your program, otherwise your
  2505.       program can look at every directory named in the environment
  2506.       variable PATH and try to find the first one that contains an
  2507.       executable file whose name matches your program's argv[0] (which
  2508.       by convention is the name of the file being executed).  By
  2509.       concatenating that directory and the value of argv[0] you'd
  2510.       probably have the right name.
  2511.  
  2512.       You can't really be sure though, since it is quite legal for one
  2513.       program to exec() another with any value of argv[0] it desires.
  2514.       It is merely a convention that new programs are exec'd with the
  2515.       executable file name in argv[0].
  2516.  
  2517.       For instance, purely a hypothetical example:
  2518.         
  2519.         #include <stdio.h>
  2520.         main()
  2521.         {
  2522.             execl("/usr/games/rogue", "vi Thesis", (char *)NULL);
  2523.         }
  2524.  
  2525.       The executed program thinks its name (its argv[0] value) is
  2526.       "vi Thesis".   (Certain other programs might also think that
  2527.       the name of the program you're currently running is "vi Thesis",
  2528.       but of course this is just a hypothetical example, don't
  2529.       try it yourself :-)
  2530.  
  2531. ------------------------------
  2532.  
  2533. Subject: How do I use popen() to open a process for reading AND writing?
  2534. Date: Thu Mar 18 17:16:55 EST 1993
  2535.  
  2536. 4.5)  How do I use popen() to open a process for reading AND writing?
  2537.  
  2538.       The problem with trying to pipe both input and output to an
  2539.       arbitrary slave process is that deadlock can occur, if both
  2540.       processes are waiting for not-yet-generated input at the same
  2541.       time.  Deadlock can be avoided only by having BOTH sides follow a
  2542.       strict deadlock-free protocol, but since that requires
  2543.       cooperation from the processes it is inappropriate for a
  2544.       popen()-like library function.
  2545.  
  2546.       The 'expect' distribution includes a library of functions that a
  2547.       C programmer can call directly.  One of the functions does the
  2548.       equivalent of a popen for both reading and writing.  It uses ptys
  2549.       rather than pipes, and has no deadlock problem.  It's portable to
  2550.       both BSD and SV.  See the next answer for more about 'expect'.
  2551.  
  2552. ------------------------------
  2553.  
  2554. Subject: How do I sleep() in a C program for less than one second?
  2555. Date: Thu Mar 18 17:16:55 EST 1993
  2556.  
  2557. 4.6)  How do I sleep() in a C program for less than one second?
  2558.  
  2559.       The first thing you need to be aware of is that all you can
  2560.       specify is a MINIMUM amount of delay; the actual delay will
  2561.       depend on scheduling issues such as system load, and could be
  2562.       arbitrarily large if you're unlucky.
  2563.  
  2564.       There is no standard library function that you can count on in
  2565.       all environments for "napping" (the usual name for short
  2566.       sleeps).  Some environments supply a "usleep(n)" function which
  2567.       suspends execution for n microseconds.  If your environment
  2568.       doesn't support usleep(), here are a couple of implementations
  2569.       for BSD and System V environments.
  2570.  
  2571.       The following code is adapted from Doug Gwyn's System V emulation
  2572.       support for 4BSD and exploits the 4BSD select() system call.
  2573.       Doug originally called it 'nap()'; you probably want to call it
  2574.       "usleep()";
  2575.  
  2576.       /*
  2577.             usleep -- support routine for 4.2BSD system call emulations
  2578.             last edit:  29-Oct-1984     D A Gwyn
  2579.       */
  2580.  
  2581.       extern int        select();
  2582.  
  2583.       int
  2584.       usleep( usec )                            /* returns 0 if ok, else -1 */
  2585.             long                usec;           /* delay in microseconds */
  2586.             {
  2587.             static struct                       /* `timeval' */
  2588.                     {
  2589.                     long        tv_sec;         /* seconds */
  2590.                     long        tv_usec;        /* microsecs */
  2591.                     }   delay;          /* _select() timeout */
  2592.  
  2593.             delay.tv_sec = usec / 1000000L;
  2594.             delay.tv_usec = usec % 1000000L;
  2595.  
  2596.             return select( 0, (long *)0, (long *)0, (long *)0, &delay );
  2597.             }
  2598.  
  2599.       On System V you might do it this way:
  2600.  
  2601.       /*
  2602.       subseconds sleeps for System V - or anything that has poll()
  2603.       Don Libes, 4/1/1991
  2604.  
  2605.       The BSD analog to this function is defined in terms of
  2606.       microseconds while poll() is defined in terms of milliseconds.
  2607.       For compatibility, this function provides accuracy "over the long
  2608.       run" by truncating actual requests to milliseconds and
  2609.       accumulating microseconds across calls with the idea that you are
  2610.       probably calling it in a tight loop, and that over the long run,
  2611.       the error will even out.
  2612.  
  2613.       If you aren't calling it in a tight loop, then you almost
  2614.       certainly aren't making microsecond-resolution requests anyway,
  2615.       in which case you don't care about microseconds.  And if you did,
  2616.       you wouldn't be using UNIX anyway because random system
  2617.       indigestion (i.e., scheduling) can make mincemeat out of any
  2618.       timing code.
  2619.  
  2620.       Returns 0 if successful timeout, -1 if unsuccessful.
  2621.  
  2622.       */
  2623.  
  2624.       #include <poll.h>
  2625.  
  2626.       int
  2627.       usleep(usec)
  2628.       unsigned int usec;                /* microseconds */
  2629.       {
  2630.             static subtotal = 0;        /* microseconds */
  2631.             int msec;                   /* milliseconds */
  2632.  
  2633.             /* 'foo' is only here because some versions of 5.3 have
  2634.              * a bug where the first argument to poll() is checked
  2635.              * for a valid memory address even if the second argument is 0.
  2636.              */
  2637.             struct pollfd foo;
  2638.  
  2639.             subtotal += usec;
  2640.             /* if less then 1 msec request, do nothing but remember it */
  2641.             if (subtotal < 1000) return(0);
  2642.             msec = subtotal/1000;
  2643.             subtotal = subtotal%1000;
  2644.             return poll(&foo,(unsigned long)0,msec);
  2645.       }
  2646.  
  2647.       Another possibility for nap()ing on System V, and probably other
  2648.       non-BSD Unices is Jon Zeeff's s5nap package, posted to
  2649.       comp.sources.misc, volume 4.  It does require a installing a
  2650.       device driver, but works flawlessly once installed.  (Its
  2651.       resolution is limited to the kernel HZ value, since it uses the
  2652.       kernel delay() routine.)
  2653.  
  2654. ------------------------------
  2655.  
  2656. Subject: How can I get setuid shell scripts to work?
  2657. Date: Thu Mar 18 17:16:55 EST 1993
  2658.  
  2659. 4.7)  How can I get setuid shell scripts to work?
  2660.  
  2661.       [ This is a long answer, but it's a complicated and frequently-asked
  2662.         question.  Thanks to Maarten Litmaath for this answer, and
  2663.         for the "indir" program mentioned below. ]
  2664.  
  2665.       Let us first assume you are on a UNIX variant (e.g. 4.3BSD or
  2666.       SunOS) that knows about so-called `executable shell scripts'.
  2667.       Such a script must start with a line like:
  2668.  
  2669.         #!/bin/sh
  2670.  
  2671.       The script is called `executable' because just like a real (binary)
  2672.       executable it starts with a so-called `magic number' indicating
  2673.       the type of the executable.  In our case this number is `#!' and
  2674.       the OS takes the rest of the first line as the interpreter for
  2675.       the script, possibly followed by 1 initial option like:
  2676.  
  2677.         #!/bin/sed -f
  2678.  
  2679.       Suppose this script is called `foo' and is found in /bin,
  2680.       then if you type:
  2681.  
  2682.         foo arg1 arg2 arg3
  2683.  
  2684.       the OS will rearrange things as though you had typed:
  2685.  
  2686.         /bin/sed -f /bin/foo arg1 arg2 arg3
  2687.  
  2688.       There is one difference though: if the setuid permission bit for
  2689.       `foo' is set, it will be honored in the first form of the
  2690.       command; if you really type the second form, the OS will honor
  2691.       the permission bits of /bin/sed, which is not setuid, of course.
  2692.  
  2693.       ----------
  2694.  
  2695.       OK, but what if my shell script does NOT start with such a `#!'
  2696.       line or my OS does not know about it?
  2697.  
  2698.       Well, if the shell (or anybody else) tries to execute it, the OS
  2699.       will return an error indication, as the file does not start with
  2700.       a valid magic number.  Upon receiving this indication the shell
  2701.       ASSUMES the file to be a shell script and gives it another try:
  2702.  
  2703.         /bin/sh shell_script arguments
  2704.  
  2705.       But we have already seen that a setuid bit on `shell_script' will
  2706.       NOT be honored in this case!
  2707.  
  2708.       ----------
  2709.  
  2710.       Right, but what about the security risks of setuid shell scripts?
  2711.  
  2712.       Well, suppose the script is called `/etc/setuid_script', starting
  2713.       with:
  2714.  
  2715.         #!/bin/sh
  2716.         
  2717.       Now let us see what happens if we issue the following commands:
  2718.  
  2719.         $ cd /tmp
  2720.         $ ln /etc/setuid_script -i
  2721.         $ PATH=.
  2722.         $ -i
  2723.  
  2724.       We know the last command will be rearranged to:
  2725.  
  2726.         /bin/sh -i
  2727.  
  2728.       But this command will give us an interactive shell, setuid to the
  2729.       owner of the script!
  2730.       Fortunately this security hole can easily be closed by making the
  2731.       first line:
  2732.  
  2733.         #!/bin/sh -
  2734.  
  2735.       The `-' signals the end of the option list: the next argument `-i'
  2736.       will be taken as the name of the file to read commands from, just
  2737.       like it should!
  2738.  
  2739.       ---------
  2740.  
  2741.       There are more serious problems though:
  2742.  
  2743.         $ cd /tmp
  2744.         $ ln /etc/setuid_script temp
  2745.         $ nice -20 temp &
  2746.         $ mv my_script temp
  2747.  
  2748.       The third command will be rearranged to:
  2749.  
  2750.         nice -20 /bin/sh - temp
  2751.  
  2752.       As this command runs so slowly, the fourth command might be able
  2753.       to replace the original `temp' with `my_script' BEFORE `temp' is
  2754.       opened by the shell!  There are 4 ways to fix this security hole:
  2755.  
  2756.         1)  let the OS start setuid scripts in a different, secure way
  2757.             - System V R4 and 4.4BSD use the /dev/fd driver to pass the
  2758.             interpreter a file descriptor for the script
  2759.  
  2760.         2)  let the script be interpreted indirectly, through a frontend
  2761.             that makes sure everything is all right before starting the
  2762.             real interpreter - if you use the `indir' program from
  2763.             comp.sources.unix the setuid script will look like this:
  2764.  
  2765.                 #!/bin/indir -u
  2766.                 #?/bin/sh /etc/setuid_script
  2767.  
  2768.         3)  make a `binary wrapper': a real executable that is setuid and
  2769.             whose only task is to execute the interpreter with the name of
  2770.             the script as an argument
  2771.  
  2772.         4)  make a general `setuid script server' that tries to locate the
  2773.             requested `service' in a database of valid scripts and upon
  2774.             success will start the right interpreter with the right
  2775.             arguments.
  2776.  
  2777.       ---------
  2778.  
  2779.       Now that we have made sure the right file gets interpreted, are
  2780.       there any risks left?
  2781.  
  2782.       Certainly!  For shell scripts you must not forget to set the PATH
  2783.       variable to a safe path explicitly.  Can you figure out why?
  2784.       Also there is the IFS variable that might cause trouble if not
  2785.       set properly.  Other environment variables might turn out to
  2786.       compromise security as well, e.g. SHELL...  Furthermore you must
  2787.       make sure the commands in the script do not allow interactive
  2788.       shell escapes!  Then there is the umask which may have been set
  2789.       to something strange...
  2790.  
  2791.       Etcetera.  You should realise that a setuid script `inherits' all
  2792.       the bugs and security risks of the commands that it calls!
  2793.  
  2794.       All in all we get the impression setuid shell scripts are quite a
  2795.       risky business!  You may be better off writing a C program instead!
  2796.  
  2797. ------------------------------
  2798.  
  2799. Subject: How can I find out which user or process has a file open ... ?
  2800. Date: Thu Mar 18 17:16:55 EST 1993
  2801.  
  2802. 4.8)  How can I find out which user or process has a file open or is using
  2803.       a particular file system (so that I can unmount it?)
  2804.  
  2805.       Use fuser (system V), fstat (BSD), ofiles (public domain) or
  2806.       pff (public domain).  These programs will tell you various things
  2807.       about processes using particular files.
  2808.  
  2809.       A port of the 4.3 BSD fstat to Dynix, SunOS and Ultrix
  2810.       can be found in archives of comp.sources.unix, volume 18.
  2811.  
  2812.       pff is part of the kstuff package, and works on quite a few systems.
  2813.       Instructions for obtaining kstuff are provided in question 3.10.
  2814.  
  2815. ------------------------------
  2816.  
  2817. Subject: How do I keep track of people who are fingering me?
  2818. From: jik@rtfm.MIT.EDU (Jonathan I. Kamens)
  2819. From: malenovi@plains.NoDak.edu (Nikola Malenovic)
  2820. Date: Mon, 23 Nov 1992 16:01:45 -0600
  2821.  
  2822. 4.9)  How do I keep track of people who are fingering me?
  2823.  
  2824.       Generally, you can't find out the userid of someone who is
  2825.       fingering you from a remote machine.  You may be able to
  2826.       find out which machine the remote request is coming from.
  2827.       One possibility, if your system supports it and assuming
  2828.       the finger daemon doesn't object, is to make your .plan file a
  2829.       "named pipe" instead of a plain file.  (Use 'mknod' to do this.)
  2830.  
  2831.       You can then start up a program that will open your .plan file
  2832.       for writing; the open will block until some other process (namely
  2833.       fingerd) opens the .plan for reading.  Now you can whatever you
  2834.       want through this pipe, which lets you show different .plan
  2835.       information every time someone fingers you.
  2836.  
  2837.       Of course, this may not work at all if your system doesn't
  2838.       support named pipes or if your local fingerd insists
  2839.       on having plain .plan files.
  2840.  
  2841.       Your program can also take the opportunity to look at the output
  2842.       of "netstat" and spot where an incoming finger connection is
  2843.       coming from, but this won't get you the remote user.
  2844.  
  2845.       Getting the remote userid would require that the remote site be
  2846.       running an identity service such as RFC 931.  There are now three
  2847.       RFC 931 implementations for popular BSD machines, and several
  2848.       applications (such as the wuarchive ftpd) supporting the server.
  2849.       For more information join the rfc931-users mailing list,
  2850.       rfc931-users-request@kramden.acf.nyu.edu.
  2851.  
  2852.       There are three caveats relating to this answer.  The first is
  2853.       that many NFS systems won't recognize the named pipe correctly.
  2854.       This means that trying to read the pipe on another machine will
  2855.       either block until it times out, or see it as a zero-length file,
  2856.       and never print it.
  2857.  
  2858.       The second problem is that on many systems, fingerd checks that
  2859.       the .plan file contains data (and is readable) before trying to
  2860.       read it.  This will cause remote fingers to miss your .plan file
  2861.       entirely.
  2862.  
  2863.       The third problem is that a system that supports named pipes
  2864.       usually has a fixed number of named pipes available on the
  2865.       system at any given time - check the kernel config file and
  2866.       FIFOCNT option.  If the number of pipes on the system exceeds the
  2867.       FIFOCNT value, the system blocks new pipes until somebody frees
  2868.       the resources.  The reason for this is that buffers are allocated
  2869.       in a non-paged memory.
  2870.  
  2871. ------------------------------
  2872.  
  2873. Subject: Is it possible to reconnect a process to a terminal ... ?
  2874. Date: Thu Mar 18 17:16:55 EST 1993
  2875.  
  2876. 4.10) Is it possible to reconnect a process to a terminal after it has
  2877.       been disconnected, e.g. after starting a program in the background
  2878.       and logging out?
  2879.  
  2880.       Most variants of Unix do not support "detaching" and "attaching"
  2881.       processes, as operating systems such as VMS and Multics support.
  2882.       However, there are two freely redistributable packages which can
  2883.       be used to start processes in such a way that they can be later
  2884.       reattached to a terminal.
  2885.  
  2886.       The first is "screen," which is described in the
  2887.       comp.sources.unix archives as "Screen, multiple windows on a CRT"
  2888.       (see the "screen-3.2" package in comp.sources.misc, volume 28.)
  2889.       This package will run on at least BSD, System V r3.2 and SCO UNIX.
  2890.  
  2891.       The second is "pty," which is described in the comp.sources.unix
  2892.       archives as a package to "Run a program under a pty session" (see
  2893.       "pty" in volume 23).  pty is designed for use under BSD-like
  2894.       system only.
  2895.  
  2896.       Neither of these packages is retroactive, i.e. you must have
  2897.       started a process under screen or pty in order to be able to
  2898.       detach and reattach it.
  2899.  
  2900. ------------------------------
  2901.  
  2902. Subject: Is it possible to "spy" on a terminal ... ?
  2903. Date: Thu Mar 18 17:16:55 EST 1993
  2904.  
  2905. 4.11) Is it possible to "spy" on a terminal, displaying the output
  2906.       that's appearing on it on another terminal?
  2907.  
  2908.       There are a few different ways you can do this, although none
  2909.       of them is perfect:
  2910.  
  2911.       * kibitz allows two (or more) people to interact with a shell
  2912.         (or any arbitary program).  Uses include:
  2913.  
  2914.         - watching or aiding another person's terminal session;
  2915.         - recording a conversation while retaining the ability to
  2916.           scroll backwards, save the conversation, or even edit it
  2917.           while in progress;
  2918.         - teaming up on games, document editing, or other cooperative
  2919.           tasks where each person has strengths and weakness that
  2920.           complement one another.
  2921.  
  2922.         kibitz comes as part of the expect distribution.  See question 3.9.
  2923.  
  2924.         kibitz requires permission from the person to be spyed upon.  To
  2925.         spy without permission requires less pleasant approaches:
  2926.  
  2927.       * You can write a program that rummages through Kernel structures
  2928.         and watches the output buffer for the terminal in question,
  2929.         displaying characters as they are output.  This, obviously, is
  2930.         not something that should be attempted by anyone who does not
  2931.         have experience working with the Unix kernel.  Furthermore,
  2932.         whatever method you come up with will probably be quite
  2933.         non-portable.
  2934.  
  2935.       * If you want to do this to a particular hard-wired terminal all
  2936.         the time (e.g. if you want operators to be able to check the
  2937.         console terminal of a machine from other machines), you can
  2938.         actually splice a monitor into the cable for the terminal.  For
  2939.         example, plug the monitor output into another machine's serial
  2940.         port, and run a program on that port that stores its input
  2941.         somewhere and then transmits it out *another* port, this one
  2942.         really going to the physical terminal.  If you do this, you have
  2943.         to make sure that any output from the terminal is transmitted
  2944.         back over the wire, although if you splice only into the
  2945.         computer->terminal wires, this isn't much of a problem.  This is
  2946.         not something that should be attempted by anyone who is not very
  2947.         familiar with terminal wiring and such.
  2948.  
  2949. ------------------------------
  2950.  
  2951. End of unix/faq Digest part 4 of 7
  2952. **********************************
  2953.  
  2954. -- 
  2955. Ted Timar - tmatimar@isgtec.com
  2956. ISG Technologies Inc., 6509 Airport Road, Mississauga, Ontario, Canada L4V 1S7
  2957. Archive-name: unix-faq/faq/part5
  2958. Version: $Id: part5,v 2.5 1994/04/28 19:25:03 tmatimar Exp tmatimar $
  2959.  
  2960. These seven articles contain the answers to some Frequently Asked
  2961. Questions often seen in comp.unix.questions and comp.unix.shell.
  2962. Please don't ask these questions again, they've been answered plenty
  2963. of times already - and please don't flame someone just because they may
  2964. not have read this particular posting.  Thank you.
  2965.  
  2966. This collection of documents is Copyright (c) 1994, Ted Timar, except
  2967. Part 6, which is Copyright (c) 1994, Pierre Lewis and Ted Timar.
  2968. All rights reserved.  Permission to distribute the collection is
  2969. hereby granted providing that distribution is electronic, no money
  2970. is involved, reasonable attempts are made to use the latest version
  2971. and all credits and this copyright notice are maintained.
  2972. Other requests for distribution will be considered.  All reasonable
  2973. requests will be granted.
  2974.  
  2975. All information here has been contributed with good intentions, but
  2976. none of it is guaranteed either by the contributors or myself to be
  2977. accurate.  The users of this information take all responsibility for
  2978. any damage that may occur.
  2979.  
  2980. Many FAQs, including this one, are available on the archive site
  2981. rtfm.mit.edu in the directory pub/usenet/news.answers.
  2982. The name under which a FAQ is archived appears in the "Archive-Name:"
  2983. line at the top of the article.  This FAQ is archived as
  2984. "unix-faq/faq/part[1-7]".
  2985.  
  2986. These articles are divided approximately as follows:
  2987.  
  2988.       1.*) General questions.
  2989.       2.*) Relatively basic questions, likely to be asked by beginners.
  2990.       3.*) Intermediate questions.
  2991.       4.*) Advanced questions, likely to be asked by people who thought
  2992.            they already knew all of the answers.
  2993.       5.*) Questions pertaining to the various shells, and the differences.
  2994.       6.*) An overview of Unix variants.
  2995.       7.*) An comparison of configuration management systems (RCS, SCCS).
  2996.  
  2997. This article includes answers to:
  2998.  
  2999.       5.1)  Can shells be classified into categories?
  3000.       5.2)  How do I "include" one shell script from within another
  3001.             shell script?
  3002.       5.3)  Do all shells have aliases?  Is there something else that
  3003.             can be used?
  3004.       5.4)  How are shell variables assigned?
  3005.       5.5)  How can I tell if I am running an interactive shell?
  3006.       5.6)  What "dot" files do the various shells use?
  3007.       5.7)  I would like to know more about the differences between the
  3008.             various shells.  Is this information available some place?
  3009.  
  3010. If you're looking for the answer to, say, question 5.5, and want to skip
  3011. everything else, you can search ahead for the regular expression "^5.5)".
  3012.  
  3013. While these are all legitimate questions, they seem to crop up in
  3014. comp.unix.questions or comp.unix.shell on an annual basis, usually
  3015. followed by plenty of replies (only some of which are correct) and then
  3016. a period of griping about how the same questions keep coming up.  You
  3017. may also like to read the monthly article "Answers to Frequently Asked
  3018. Questions" in the newsgroup "news.announce.newusers", which will tell
  3019. you what "UNIX" stands for.
  3020.  
  3021. With the variety of Unix systems in the world, it's hard to guarantee
  3022. that these answers will work everywhere.  Read your local manual pages
  3023. before trying anything suggested here.  If you have suggestions or
  3024. corrections for any of these answers, please send them to to
  3025. tmatimar@isgtec.com.
  3026.  
  3027. ----------------------------------------------------------------------
  3028.  
  3029. Subject: Can shells be classified into categories?
  3030. From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  3031. Date: Wed, 7 Oct 92 14:28:18 -0500
  3032.  
  3033.  
  3034. 5.1)  Can shells be classified into categories?
  3035.  
  3036.       In general there are two main class of shells.  The first class
  3037.       are those shells derived from the Bourne shell which includes sh,
  3038.       ksh, bash, and zsh.  The second class are those shells derived
  3039.       from C shell and include csh and tcsh.  In addition there is rc
  3040.       which most people consider to be in a "class by itself" although
  3041.       some people might argue that rc belongs in the Bourne shell class.
  3042.  
  3043.       With the classification above, using care, it is possible to
  3044.       write scripts that will work for all the shells from the Bourne
  3045.       shell category, and write other scripts that will work for all of
  3046.       the shells from the C shell category.
  3047.  
  3048. ------------------------------
  3049.  
  3050. Subject: How do I "include" one shell script from within another shell script?
  3051. From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  3052. Date: Wed, 7 Oct 92 14:28:18 -0500
  3053.  
  3054. 5.2)  How do I "include" one shell script from within another shell script?
  3055.  
  3056.       All of the shells from the Bourne shell category (including rc)
  3057.       use the "." command.  All of the shells from the C shell category
  3058.       use "source".
  3059.  
  3060. ------------------------------
  3061.  
  3062. Subject: Do all shells have aliases?  Is there something else that can be used?
  3063. From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  3064. Date: Wed, 7 Oct 92 14:28:18 -0500
  3065.  
  3066. 5.3)  Do all shells have aliases?  Is there something else that can be used?
  3067.  
  3068.       All of the major shells other than sh have aliases, but they
  3069.       don't all work the same way.  For example, some don't accept
  3070.       arguments.
  3071.       
  3072.       Although not strictly equivalent, shell functions (which exist in
  3073.       most shells from the Bourne shell category) have almost the same
  3074.       functionality of aliases.  Shell functions can do things that
  3075.       aliases can't do.  Shell functions did not exist in bourne shells
  3076.       derived from Version 7 Unix, which includes System III and BSD 4.2.
  3077.       BSD 4.3 and System V shells do support shell functions.
  3078.       
  3079.       Use unalias to remove aliases and unset to remove functions.
  3080.  
  3081. ------------------------------
  3082.  
  3083. Subject: How are shell variables assigned?
  3084. From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  3085. Date: Wed, 7 Oct 92 14:28:18 -0500
  3086.  
  3087. 5.4)  How are shell variables assigned?
  3088.  
  3089.       The shells from the C shell category use "set variable=value" for
  3090.       variables local to the shell and "setenv variable value" for
  3091.       environment variables.  To get rid of variables in these shells
  3092.       use unset and unsetenv.  The shells from the Bourne shell
  3093.       category use "variable=value" and may require an "export
  3094.       VARIABLE_NAME" to place the variable into the environment.  To
  3095.       get rid of the variables use unset.
  3096.  
  3097. ------------------------------
  3098.  
  3099. Subject: How can I tell if I am running an interactive shell?
  3100. From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  3101. From: dws@ssec.wisc.edu (DaviD W. Sanderson)
  3102. Date: Fri, 23 Oct 92 11:59:19 -0600
  3103.  
  3104. 5.5)  How can I tell if I am running an interactive shell?
  3105.  
  3106.       In the C shell category, look for the variable $prompt.
  3107.  
  3108.       In the Bourne shell category, you can look for the variable $PS1,
  3109.       however, it is better to check the variable $-.  If $- contains
  3110.       an 'i', the shell is interactive.  Test like so:
  3111.  
  3112.           case $- in
  3113.           *i*)    # do things for interactive shell
  3114.                   ;;
  3115.           *)      # do things for non-interactive shell
  3116.                   ;;
  3117.           esac
  3118.  
  3119. ------------------------------
  3120.  
  3121. Subject: What "dot" files do the various shells use?
  3122. From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  3123. From: tmb@idiap.ch (Thomas M. Breuel)
  3124. Date: Wed, 28 Oct 92 03:30:36 +0100
  3125.  
  3126. 5.6)  What "dot" files do the various shells use?
  3127.  
  3128.       Although this may not be a complete listing, this provides the
  3129.       majority of information.
  3130.  
  3131.       csh
  3132.           Some versions have system-wide .cshrc and .login files.  Every
  3133.           version puts them in different places.
  3134.  
  3135.           Start-up (in this order):
  3136.               .cshrc   - always.
  3137.               .login   - login shells.
  3138.  
  3139.           Upon termination:
  3140.               .logout  - login shells.
  3141.  
  3142.           Others:
  3143.               .history - saves the history (based on $savehist).
  3144.  
  3145.       tcsh
  3146.           Start-up (in this order):
  3147.               /etc/csh.cshrc - always.
  3148.               /etc/csh.login - login shells.
  3149.               .tcshrc        - always.
  3150.               .cshrc         - if no .tcshrc was present.
  3151.               .login         - login shells
  3152.  
  3153.           Upon termination:
  3154.               .logout        - login shells.
  3155.  
  3156.           Others:
  3157.               .history       - saves the history (based on $savehist).
  3158.               .cshdirs       - saves the directory stack.
  3159.  
  3160.       sh
  3161.           Start-up (in this order):
  3162.               /etc/profile - login shells.
  3163.               .profile     - login shells.
  3164.  
  3165.           Upon termination:
  3166.               any command (or script) specified using the command:
  3167.                  trap "command" 0
  3168.  
  3169.       ksh
  3170.           Start-up (in this order):
  3171.               /etc/profile - login shells.
  3172.               .profile     - login shells.
  3173.               $ENV         - always, if it is set.
  3174.  
  3175.           Upon termination:
  3176.               any command (or script) specified using the command:
  3177.                  trap "command" 0
  3178.  
  3179.       bash
  3180.           Start-up (in this order):
  3181.               /etc/profile  - login shells.
  3182.               .bash_profile - login shells.
  3183.               .profile      - login if no .bash_profile is present.
  3184.               .bashrc       - interactive non-login shells.
  3185.               $ENV          - always, if it is set.
  3186.  
  3187.           Upon termination:
  3188.               .bash_logout  - login shells.
  3189.  
  3190.           Others:
  3191.               .inputrc      - Readline initialization.
  3192.  
  3193.       zsh
  3194.           Start-up (in this order):
  3195.               .zshenv   - always, unless -f is specified.
  3196.               .zprofile - login shells.
  3197.               .zshrc    - interactive shells, unless -f is specified.
  3198.               .zlogin   - login shells.
  3199.  
  3200.           Upon termination:
  3201.               .zlogout  - login shells.
  3202.  
  3203.       rc
  3204.           Start-up:
  3205.               .rcrc - login shells
  3206.  
  3207. ------------------------------
  3208.  
  3209. Subject: I would like to know more about the differences ... ?
  3210. From: wicks@dcdmjw.fnal.gov (Matthew Wicks)
  3211. Date: Wed, 7 Oct 92 14:28:18 -0500
  3212.  
  3213. 5.7)  I would like to know more about the differences between the
  3214.       various shells.  Is this information available some place?
  3215.  
  3216.       A very detailed comparison of sh, csh, tcsh, ksh, bash, zsh, and
  3217.       rc is available via anon.  ftp in several places:
  3218.  
  3219.       cs.uwp.edu (131.210.1.4):pub/vi/docs/shell-100.BetaA.Z
  3220.       utsun.s.u-tokyo.ac.jp:misc/vi-archive/docs/shell-100.BetaA.Z
  3221.  
  3222.       This file compares the flags, the programming syntax,
  3223.       input/output redirection, and parameters/shell environment
  3224.       variables.  It doesn't discuss what dot files are used and the
  3225.       inheritance for environment variables and functions.
  3226.  
  3227. ------------------------------
  3228.  
  3229. End of unix/faq Digest part 5 of 7
  3230. **********************************
  3231.  
  3232. -- 
  3233. Ted Timar - tmatimar@isgtec.com
  3234. ISG Technologies Inc., 6509 Airport Road, Mississauga, Ontario, Canada L4V 1S7
  3235. Archive-name: unix-faq/faq/part6
  3236. Version: $Id: part6,v 2.5 1994/04/28 19:25:03 tmatimar Exp tmatimar $
  3237.  
  3238. These seven articles contain the answers to some Frequently Asked
  3239. Questions often seen in comp.unix.questions and comp.unix.shell.
  3240. Please don't ask these questions again, they've been answered plenty
  3241. of times already - and please don't flame someone just because they may
  3242. not have read this particular posting.  Thank you.
  3243.  
  3244. This collection of documents is Copyright (c) 1994, Ted Timar, except
  3245. Part 6, which is Copyright (c) 1994, Pierre Lewis and Ted Timar.
  3246. All rights reserved.  Permission to distribute the collection is
  3247. hereby granted providing that distribution is electronic, no money
  3248. is involved, reasonable attempts are made to use the latest version
  3249. and all credits and this copyright notice are maintained.
  3250. Other requests for distribution will be considered.  All reasonable
  3251. requests will be granted.
  3252.  
  3253. All information here has been contributed with good intentions, but
  3254. none of it is guaranteed either by the contributors or myself to be
  3255. accurate.  The users of this information take all responsibility for
  3256. any damage that may occur.
  3257.  
  3258. Many FAQs, including this one, are available on the archive site
  3259. rtfm.mit.edu in the directory pub/usenet/news.answers.
  3260. The name under which a FAQ is archived appears in the "Archive-Name:"
  3261. line at the top of the article.  This FAQ is archived as
  3262. "unix-faq/faq/part[1-7]".
  3263.  
  3264. These articles are divided approximately as follows:
  3265.  
  3266.       1.*) General questions.
  3267.       2.*) Relatively basic questions, likely to be asked by beginners.
  3268.       3.*) Intermediate questions.
  3269.       4.*) Advanced questions, likely to be asked by people who thought
  3270.            they already knew all of the answers.
  3271.       5.*) Questions pertaining to the various shells, and the differences.
  3272.       6.*) An overview of Unix variants.
  3273.       7.*) An comparison of configuration management systems (RCS, SCCS).
  3274.  
  3275. This article includes answers to:
  3276.  
  3277.       6.1)  Disclaimer, introduction and acknowledgements.
  3278.       6.2)  A very brief look at Unix history.
  3279.       6.3)  Main Unix flavors.
  3280.       6.4)  Unix Standards.
  3281.       6.5)  Identifying your Unix flavor.
  3282.       6.6)  Brief notes on some well-known (commercial/PD) Unices.
  3283.       6.7)  Real-time Unices.
  3284.       6.8)  Unix glossary.
  3285.  
  3286. If you're looking for the answer to, say, question 6.5, and want to skip
  3287. everything else, you can search ahead for the regular expression "^6.5)".
  3288.  
  3289. While these are all legitimate questions, they seem to crop up in
  3290. comp.unix.questions or comp.unix.shell on an annual basis, usually
  3291. followed by plenty of replies (only some of which are correct) and then
  3292. a period of griping about how the same questions keep coming up.  You
  3293. may also like to read the monthly article "Answers to Frequently Asked
  3294. Questions" in the newsgroup "news.announce.newusers", which will tell
  3295. you what "UNIX" stands for.
  3296.  
  3297. With the variety of Unix systems in the world, it's hard to guarantee
  3298. that these answers will work everywhere.  Read your local manual pages
  3299. before trying anything suggested here.  If you have suggestions or
  3300. corrections for any of these answers, please send them to to
  3301. tmatimar@isgtec.com.
  3302.  
  3303. ----------------------------------------------------------------------
  3304.  
  3305. Subject: Disclaimer, introduction and acknowledgements.
  3306. From: "Pierre (P.) Lewis" <lew@bnr.ca>
  3307. Date: Mon May 30 15:44:28 EDT 1994
  3308. X-Version: 2.6
  3309.  
  3310. 6.1)  Disclaimer, introduction and acknowledgements.
  3311.  
  3312.       The following is offered with no guarantee as to accuracy or
  3313.       completeness.  I have done what I can in the time available,
  3314.       often with conflicting information, and it still is very much work
  3315.       in progress.  I hope to keep improving this summary.  Comments and
  3316.       corrections welcome:  lew@bnr.ca.
  3317.  
  3318.       First a short definition.  By Unix we mean an operating system
  3319.       typically written in C, with a hierarchical file system,
  3320.       integration of file and device I/O, whose system call interface
  3321.       includes services such as fork(), pipe(), and whose user
  3322.       interface includes tools such as cc, troff, grep, awk, and a
  3323.       choice of shell.  Note that UNIX is a registered trademark of USL
  3324.       (AT&T), but will be used here in its generic sense.
  3325.  
  3326.       Most Unices (the more common plural form) are derived more or
  3327.       less directly from AT&T code (some code from the first C version
  3328.       is presumably still left in most), but there are also clones
  3329.       (i.e. Unix-compatible systems with no AT&T code).
  3330.  
  3331.       In addition, there are also Unix-like environments (e.g. VOS)
  3332.       sitting on top of other OSs, and OSs inspired from Unix (yes,
  3333.       even DOS!).  These are not covered here.  Little on real-time
  3334.       Unices yet (although more is planned).
  3335.  
  3336.       Unix comes in an incredible variety of flavors.  This is to a
  3337.       large extent due to availability of sources and the ease of
  3338.       porting and modifying Unix.  Typically, a vendor of Unix will
  3339.       start with one basic flavor (see below), take ideas/code from the
  3340.       other major flavor, add and change many things, etc.  This
  3341.       results in yet another new Unix flavor.  Today, there are
  3342.       literally hundreds of Unices available, the closest thing to
  3343.       standard Unix being (by definition) System V.
  3344.  
  3345.       This answer was put together mostly from information on the net
  3346.       and email.  Some specific sources are also mentioned in the
  3347.       appropriate sections.
  3348.  
  3349.       Acknowledgements: (in addition to references): pat@bnr.ca,
  3350.       guy@auspex.com, pen@lysator.liu.se, mikes@ingres.com,
  3351.       mjd@saul.cis.upenn.edu, root%candle.uucp@ls.com, ee@atbull.bull.co.at,
  3352.       Aaron_Dailey@stortek.com, ralph@dci.pinetree.org, sbdah@mcshh.hanse.de,
  3353.       macmach@andrew.cmu.edu, jwa@alw.nih.gov [4.4BSD], roeber@axpvms.cern.ch,
  3354.       bob@pta.pyramid.com.au, bad@flatlin.ka.sub.org, m5@vail.tivoli.com,
  3355.       dan@fch.wimsey.bc.ca, jlbrand@uswnvg.com, jpazer@usl.com,
  3356.       ym@satelnet.org, merritt@gendev.slc.paramax.com, quinlan@yggdrasil.com,
  3357.       steve@rudolph.ssd.csd.harris.com, bud@heinous.isca.uiowa.edu,
  3358.       many that I forgot, and all the other
  3359.       folks whose posts I read. Many thanks!
  3360.  
  3361. ------------------------------
  3362.  
  3363. Subject: A very brief look at Unix history.
  3364. From: "Pierre (P.) Lewis" <lew@bnr.ca>
  3365. Date: Mon May 30 15:44:28 EDT 1994
  3366. X-Version: 2.6
  3367.  
  3368. 6.2)  A very brief look at Unix history.
  3369.  
  3370.       Unix history goes back to 1969 and the famous "little-used PDP-7
  3371.       in a corner" on which Ken Thompson, Dennis Ritchie (the R in K&R)
  3372.       and others started work on what was to become Unix.  The name
  3373.       "Unix" was intended as a pun on Multics (and was written "Unics"
  3374.       at first -- UNiplexed Information and Computing System).
  3375.  
  3376.       For the first 10 years, Unix development was essentially confined
  3377.       to Bell Labs.  These initial versions were labeled "Version n" or
  3378.       "Nth Edition" (of the manuals), and were for DEC's PDP-11 (16
  3379.       bits) and later VAXen (32 bits).  Some significant versions
  3380.       include:
  3381.  
  3382.       V1 (1971):  1st Unix version, in assembler on a PDP-11/20.
  3383.          Included file system, fork(), roff, ed.  Was used as a text
  3384.          processing tool for preparation of patents.  Pipe() appeared
  3385.          first in V2!
  3386.  
  3387.       V4 (1973):  Rewritten in C, which is probably the most
  3388.          significant event in this OS's history: it means Unix can be
  3389.          ported to a new hardware in months, and changes are easy.  The
  3390.          C language was originally designed for the Unix operating
  3391.          system, and hence there is a strong synergy between C and Unix.
  3392.  
  3393.       V6 (1975):  First version of Unix widely available outside
  3394.          Bell Labs (esp.  in universities).  This was also the start of
  3395.          Unix diversity and popularity.  1.xBSD (PDP-11) was derived
  3396.          from this version.  J. Lions published "A commentary on the
  3397.          Unix Operating System" based on V6.
  3398.  
  3399.       V7 (1979):  For many, this is the "last true Unix", an
  3400.          "improvement over all preceding and following Unices"
  3401.          [Bourne].  It included full K&R C, uucp, Bourne shell.  V7 was
  3402.          ported to the VAX as 32V.  The V7 kernel was a mere 40
  3403.          Kbytes!
  3404.  
  3405.          Here (for reference) are the system calls of V7:
  3406.             _exit, access, acct, alarm, brk, chdir, chmod, chown,
  3407.             chroot, close, creat, dup, dup2, exec*, exit, fork, fstat,
  3408.             ftime, getegid, geteuid, getgid, getpid, getuid, gtty,
  3409.             indir, ioctl, kill, link, lock, lseek, mknod, mount,
  3410.             mpxcall, nice, open, pause, phys, pipe, pkoff, pkon,
  3411.             profil, ptrace, read, sbrk, setgid, setuid, signal, stat,
  3412.             stime, stty, sync, tell, time, times, umask, umount,
  3413.             unlink, utime, wait, write.
  3414.  
  3415.       These Vn versions were developed by the Computer Research Group
  3416.       (CRG) of Bell Labs.  Another group, the Unix System Group (USG),
  3417.       was responsible for support.  A third group at Bell Labs was also
  3418.       involved in Unix development, the Programmer's WorkBench (PWB),
  3419.       to which we owe, for example, sccs, named pipes and other
  3420.       important ideas.  Both groups were merged into Unix System
  3421.       Development Lab in 1983.
  3422.  
  3423.       Another variant of Unix was CB Unix (Columbus Unix) from the Columbus
  3424.       branch of Bell Labs, responsible of Operations Support Systems. Its
  3425.       main contribution was parts of SV IPC.
  3426.  
  3427.       Work on Unix continued at Bell Labs in the 1980s.  The V series
  3428.       was further developed by the CRG (Stroustrup mentions V10 in the
  3429.       2nd edition of his book on C++), but we don't seem to hear much
  3430.       about this otherwise.  The company now responsible for Unix
  3431.       (System V) is called Unix System Laboratories (USL) and is
  3432.       majority-owned by AT&T.  Novell has bought USL (early 93)?!
  3433.       Novell has given rights to the "UNIX" trademark to X/Open (late 93).
  3434.  
  3435.       But much happened to Unix outside AT&T, especially at Berkeley
  3436.       (where the other major flavor comes from).  Vendors (esp. of
  3437.       workstations) also contributed much (e.g. Sun's NFS).
  3438.  
  3439.       The book "Life with Unix" by Don Libes and Sandy Ressler is
  3440.       fascinating reading for anyone interested in Unix, and covers a
  3441.       lot of the history, interactions, etc..  Much in the present
  3442.       section is summarized from this book.
  3443.  
  3444. ------------------------------
  3445.  
  3446. Subject: Main Unix flavors.
  3447. From: "Pierre (P.) Lewis" <lew@bnr.ca>
  3448. Date: Mon May 30 15:44:28 EDT 1994
  3449. X-Version: 2.7
  3450.  
  3451. 6.3)  Main Unix flavors.
  3452.  
  3453.       Until recently, there were basically two main flavors of Unix:
  3454.       System V (five) from AT&T, and the Berkeley Software Distribution
  3455.       (BSD).  SVR4 is essentially a merge of these two flavors.  End
  3456.       '91, OSF/1 from the Open Software Foundation was released (as a
  3457.       direct competitor to System V) and may (future will tell) change
  3458.       this picture.
  3459.  
  3460.       The following lists the main releases and features of System V,
  3461.       BSD and OSF/1.
  3462.  
  3463.       System V from AT&T.  Typical of Intel hardware.  Most often
  3464.          ported Unix, typically with BSD enhancements (csh, job
  3465.          control, termcap, curses, vi, symbolic links).  System V
  3466.          evolution is now overseen by Unix International (UI).  UI
  3467.          members include AT&T, Sun, ....
  3468.          Newsgroup: comp.unix.sysv[23]86.  Main releases:
  3469.  
  3470.          - System III (1982): first commercial Unix from AT&T
  3471.            - FIFOs (named pipes)  (later?)
  3472.  
  3473.          - System V (1983):
  3474.            - IPC package (shm, msg, sem)
  3475.  
  3476.          - SVR2 (1984):
  3477.            - shell functions (sh)
  3478.            - SVID (System V Interface Definition)
  3479.  
  3480.          - SVR3 (1986) for ? platforms:
  3481.            - STREAMS (inspired by V8), poll(), TLI (network software)
  3482.            - RFS
  3483.            - shared libs
  3484.            - SVID 2
  3485.            - demand paging (if hardware supports)
  3486.  
  3487.          - SVR3.2:
  3488.            - merge with Xenix (Intel 80386)
  3489.            - networking
  3490.  
  3491.          - SVR4 (1988), mainstream of Unix implementations, merge of
  3492.            System V, BSD, and SunOS.
  3493.            - From SVR3: sysadmin, terminal I/F, printer (from BSD?),
  3494.              RFS, STREAMS, uucp
  3495.            - From BSD: FFS, TCP/IP, sockets, select(), csh
  3496.            - From SunOS: NFS, OpenLook GUI, X11/NeWS, virtual memory
  3497.              subsystem with memory-mapped files, shared libraries
  3498.              (!= SVR3 ones?)
  3499.            - ksh
  3500.            - ANSI C
  3501.            - Internationalization (8-bit clean)
  3502.            - ABI (Application Binary Interface -- routines instead of traps)
  3503.            - POSIX, X/Open, SVID3
  3504.  
  3505.          - SVR4.1
  3506.            - async I/O (from SunOS?)
  3507.  
  3508.          - SVR4.2 (based on SVR4.1ES)
  3509.            - Veritas FS, ACLs
  3510.            - Dynamically loadable kernel modules
  3511.  
  3512.          - Future:
  3513.            - SVR4 MP (multiprocessor)
  3514.            - Use of Chorus microkernel?
  3515.  
  3516.       Berkeley Software Distribution (BSD).  Typical of VAXen, RISCs,
  3517.          many workstations.  More dynamic, research versions now than
  3518.          System V.  BSD is responsible for much of the popularity of
  3519.          Unix.  Most enhancements to Unix started here.  The group
  3520.          responsible at UCB (University of California at Berkeley) is
  3521.          the Computer System Research Group (CSRG).  They closed down
  3522.          in 1992.  Newsgroup: comp.unix.bsd.  Main releases:
  3523.  
  3524.          (much reorganized wrt dates and releases, hope it's converging)
  3525.  
  3526.          - 2.xBSD (1978) for PDP-11, still of significance? (2.11BSD
  3527.            was released in 1992!).
  3528.            - csh
  3529.  
  3530.          - 3BSD (1978):
  3531.            - virtual memory
  3532.  
  3533.          - 4.?BSD:
  3534.            - termcap, curses
  3535.            - vi
  3536.  
  3537.          - 4.0BSD (1980):
  3538.  
  3539.          - 4.1BSD (?): base of later AT&T CRG versions
  3540.            - job control
  3541.            - automatic kernel config
  3542.            - vfork()
  3543.  
  3544.          - 4.2BSD (1983):
  3545.            - TCP/IP, sockets, ethernet
  3546.            - UFS: long file names, symbolic links
  3547.            - new reliable signals (4.1 reliable signals now in SVR3)
  3548.            - select()
  3549.  
  3550.          - 4.3BSD (1986) for VAX, ?:
  3551.          - 4.3 Tahoe (1988): 4.3BSD with sources, support for Tahoe
  3552.            (32-bit supermini)
  3553.            - Fat FFS
  3554.            - New TCP algorithms
  3555.          - 4.3 Reno (1990) for VAX, Tahoe, HP 9000/300:
  3556.            - most of P1003.1
  3557.            - NFS (from Sun)
  3558.            - MFS (memory file system)
  3559.            - OSI: TP4, CLNP, ISODE's FTAM, VT and X.500;  SLIP
  3560.            - Kerberos
  3561.  
  3562.          - Net1 (?) and Net2 (June 1991) tapes: that portion of BSD which
  3563.            requires no USL copyright
  3564.  
  3565.          - 4.4BSD (alpha June 1992) for HP 9000/300, Sparc, 386, DEC, others;
  3566.            neither VAX nor Tahoe; two versions, lite (~Net2 contents plus,
  3567.            fixes and new architectures) and encumbered (everything, requires
  3568.            USL license):
  3569.            - new virtual memory system (VMS) based on Mach 2.5
  3570.            - virtual filesystem interface, log-structured filesystem, size
  3571.              of local filesystem up to 2^63, NFS (freely redistributable,
  3572.              works with Sun's, over UDP or TCP)
  3573.            - ISO/OSI networking support (based on ISODE): TP4/CLNP/802.3 and
  3574.              TP0/CONS/X.25, session and above in user space;  FTAM, VT, X.500.
  3575.            - most of POSIX.1 (esp. new terminal driver a la SV), much of
  3576.              POSIX.2, improved job control; ANSI C headers
  3577.            - Kerberos integrated with much of the system (incl. NFS)
  3578.            - TCP/IP enhancements (incl. header prediction, SLIP)
  3579.            - important kernel changes (new system call convention, ...)
  3580.            - other improvements: FIFOs, byte-range file locking
  3581.            Official 4.4BSD release was expected within 6 months of above.
  3582.  
  3583.       The Open Software Foundation (OSF) released its Unix called OSF/1
  3584.          end of 1991.  Still requires an SVR2 license.
  3585.          Compatible/compliant with SVID 2 (and 3 coming), POSIX,
  3586.          X/Open, etc..  OSF members include Apollo, Dec, HP, IBM, ....
  3587.  
  3588.          - OSF/1 (1991):
  3589.            - based on Mach 2.5 kernel
  3590.            - symmetric multiprocessing, parallelized kernel, threads
  3591.            - logical volumes, disk mirroring, UFS (native), S5 FS, NFS
  3592.            - enhanced security (B1 with some B2, B3; or C2), 4.3BSD admin
  3593.            - STREAMS, TLI/XTI, sockets
  3594.            - shared libs, dynamic loader (incl. kernel)
  3595.            - Motif GUI
  3596.  
  3597.          - Release 1.3 (Jun 94)
  3598.            - Based on MACH 3.0 Micro-kernel
  3599.            - Conformant with current draft of Specification 1170
  3600.              (considered for standardization in X/Open's Fast Track process)
  3601.            - Data Capture I/F, Common Data Link I/F,
  3602.            - ISO 10646 and 64-bit support.
  3603.            - OSF/1 MK (mikrokernel) based on Mach 3.0
  3604.  
  3605.       This list of major flavors should probably also include Xenix
  3606.       (Microsoft) which has been the basis for many ports.  Derived from V7,
  3607.       S III and finally System V, it is similar externally but significantly
  3608.       changed internally (performance-tuned for micros).
  3609.  
  3610.  
  3611.       Two very good books describe the internals of the two main flavors.
  3612.       These are:
  3613.       - System V: "Design of the Unix Operating SYstem", M.J. Bach.
  3614.       - BSD: "Design and Implementation of the 4.3BSD Unix Operating System",
  3615.         Leffler, McKusick, Karels, Quaterman.
  3616.       For a good introduction to OSF/1 (not quite as technical as the
  3617.       previous two), see: "Guide to OSF/1, A Technical Synopsis",
  3618.       published by O'Reilly.  On SunOS, "Virtual Memory Architecture in
  3619.       SunOS" and "Shared Libraries in SunOS" in Summer 1989 USENIX
  3620.       Proceedings.
  3621.  
  3622.       A good set of articles on where Unix is going is "Unix Variants"
  3623.       in the Apr 92 issue of Unix Review.  Other good sources of
  3624.       information include the bsd-faq file, and many of the newsgroups
  3625.       mentioned in the text.
  3626.  
  3627. ------------------------------
  3628.  
  3629. Subject: Unix Standards.
  3630. From: "Pierre (P.) Lewis" <lew@bnr.ca>
  3631. Date: Mon May 30 15:44:28 EDT 1994
  3632. X-Version: 2.6
  3633.  
  3634. 6.4)  Unix Standards.
  3635.  
  3636.       This section briefly describes the more important standards
  3637.       relevant to Unix.
  3638.  
  3639.       - IEEE:
  3640.         - 802.x (LAN) standards (LLC, ethernet, token ring, token bus)
  3641.         - POSIX (ISO 9945?): Portable Operating System I/F (Unix, VMS
  3642.           and OS/2!) (only ? have been finalized at this point)
  3643.           - 1003.1:  library procedures (mostly system calls) -- roughly V7
  3644.                      except for signals and terminal I/F (1990)
  3645.           - 1003.2:  shell and utilities
  3646.           - 1003.3:  test methods and conformance
  3647.           - 1003.4:  real-time: binary semaphores, process memory
  3648.                      locking, memory-mapped files, shared memory,
  3649.                      priority scheduling, real-time signals, clocks and
  3650.                      timers, IPC message passing, synchronized I/O,
  3651.                      asynchronous I/O, real-time files
  3652.           - 1003.5:  Ada language bindings
  3653.           - 1003.6:  security
  3654.           - 1003.7:  system admin (incl. printing)
  3655.           - 1003.8:  transparent file access
  3656.           - 1003.9:  FORTRAN language bindings
  3657.           - 1003.10: super computing
  3658.           - 1003.12: protocol-independent I/Fs
  3659.           - 1003.13: real-time profiles
  3660.           - 1003.15: supercomputing batch I/Fs
  3661.           - 1003.16: C-language bindings (?)
  3662.           - 1003.17: directory services
  3663.           - 1003.18: POSIX standardized profile
  3664.           - 1003.19: FORTRAN 90 language bindings
  3665.  
  3666.       - X/Open (consortium of vendors, founded 1984):
  3667.         - X/Open Portability Guides (XPGn):
  3668.           - XPG2 (1987), strong SV influence
  3669.             Vol 1:  commands and utilities
  3670.             Vol 2:  system calls and libraries
  3671.             Vol 3:  terminal I/F (curses, termio), IPC (SV),
  3672.                     internationalization
  3673.             Vol 4:  programming languages (C, COBOL!)
  3674.             Vol 5:  data management (ISAM, SQL)
  3675.           - XPG3 (1989) adds: X11 API
  3676.           - XPG4 (1992) adds: XTI?   22 components
  3677.         - XOM series of interfaces:
  3678.           - XOM (X/Open Object Management) generic I/F mechanisms for
  3679.             following
  3680.           - XDS (X/Open Directory Service)
  3681.           - XMH (X/Open Mail ??)
  3682.           - XMP (X/Open Management Protocols) -- not Bull's CM API?
  3683.         - X/Open now has the rights to the "UNIX" trademark (late 93);
  3684.         - "Spec 1170"
  3685.           - This specification is being prepared describing a common API
  3686.             which vendors wanting to use the name "UNIX" will have to comply
  3687.             to (when test suites are available). Merge of SVID, OSF's AES
  3688.             and other stuff.
  3689.  
  3690.       - AT&T
  3691.         - System V Interface Definition (SVID)
  3692.           - SVID1 (1985, SVR2)
  3693.             Vol 1:  system calls and libraries (similar to XPG2.1)
  3694.           - SVID2 (1986, SVR3)
  3695.             Vol 1:  system calls and libraries (base, kernel extensions)
  3696.             Vol 2:  commands and utilities (base, advanced, admin, software
  3697.                     development), terminal I/F
  3698.             Vol 3:  terminal I/F (again), STREAMS and TLI, RFS
  3699.           - SVID3 (19??, SVR4) adds
  3700.             Vol 4:  ??  &c
  3701.         - APIs
  3702.           - Transport Library Interface (TLI)
  3703.           - ACSE/Presentation Library Interface (APLI)
  3704.  
  3705. ------------------------------
  3706.  
  3707. Subject: Identifying your Unix flavor.
  3708. From: "Pierre (P.) Lewis" <lew@bnr.ca>
  3709. Date: Mon May 30 15:44:28 EDT 1994
  3710. X-Version: 2.6
  3711.  
  3712. 6.5)  Identifying your Unix flavor.
  3713.  
  3714.       This section lists a number of things you can look at in
  3715.       attempting to identify the base flavor of your Unix.  Given the
  3716.       significant exchange of code and ideas between the various
  3717.       flavors and the many changes made by vendors, any statement such
  3718.       as "this Unix is an SVR2" is at best a statistical statement
  3719.       (except for some SVRn ports).  Also many Unices offer most of
  3720.       both worlds (either mixed as in SunOS or strictly separated as in
  3721.       Apollo?).  So this section is perhaps not very useful...
  3722.  
  3723.       The list of features in previous sections can also help.  For
  3724.       example, if a system has a poll(2) but no select(2), it is highly
  3725.       probable that it is derived from SVR3.  Also the name of the OS
  3726.       can provide a clue, as well as the logon message (e.g.  SGI's
  3727.       "IRIX SVR3.3.2") or the output of "uname -a" command.  Available
  3728.       commands can also provide hints but this is probably less
  3729.       reliable than kernel features.  For example, the type of terminal
  3730.       initialization (inittab or ttys) is a more reliable indicator
  3731.       than the print subsystem.
  3732.  
  3733.       Feature           Typical in SVRx         Typical in xBSD
  3734.  
  3735.       kernel name       /unix                   /vmunix
  3736.       terminal init     /etc/inittab            /etc/ttys (only getty to 4.3)
  3737.       boot init         /etc/rc.d directories   /etc/rc.* files
  3738.       mounted FSs       /etc/mnttab             /etc/mtab
  3739.       usual shell       sh, ksh                 csh, #! hack
  3740.       native FS         S5 (blk: 512-2K)        UFS (blk: 4K-8K)
  3741.                         file names <= 14 bytes  file names < 255 bytes
  3742.       groups            need newgrp(1)          automatic membership
  3743.                         SVR4: multiple groups
  3744.       print subsystem   lp, lpstat, cancel      lpr, lpq, lprm (lpd daemon) ??
  3745.       terminal control  termio, terminfo,       termios (sgtty before 4.3reno)
  3746.                         SVR4: termios (POSIX)   termcap
  3747.       job control       >= SVR4                 yes
  3748.       ps command        ps -ef                  ps -aux
  3749.       multiple wait     poll                    select
  3750.       string fcns       memset, memcpy          bzero, bcopy
  3751.       process mapping   /proc  (SVR4)
  3752.  
  3753. ------------------------------
  3754.  
  3755. Subject: Brief notes on some well-known (commercial/PD) Unices.
  3756. From: "Pierre (P.) Lewis" <lew@bnr.ca>
  3757. Date: Mon May 30 15:44:28 EDT 1994
  3758. X-Version: 2.6
  3759.  
  3760. 6.6)  Brief notes on some well-known (commercial/PD) Unices.
  3761.  
  3762.       (I am not at all satisfied with this section, unfortunately I
  3763.       have neither the time nor the documents to make it much better
  3764.       (wrt contents).  Should only list Unices known by a reasonably
  3765.       wide audience.  Small and non-US Unices welcome, e.g. Eurix.  In
  3766.       need of reformatting)
  3767.  
  3768.       This section lists (in alphabetical order) some of the better
  3769.       known Unices along with a brief description of their nature.
  3770.       Unfortunately, it's out-of-date almost by definition...
  3771.  
  3772.       (sorted alpha, ignoring numbers and other chars)
  3773.  
  3774.       AIX:  IBM's Unix, based on SVR2 (later up to SVR3.2?) with varying
  3775.          degrees of BSD extensions, for various hardwares.  Proprietary
  3776.          system admin (SMIT).  Both 850 and Latin-1 CPs.  Quite
  3777.          different from most Unices and among themselves.
  3778.          Newsgroup: comp.unix.aix.
  3779.          - 1.x (for 386 PS/2)
  3780.          - 2.x (for PC RTs)
  3781.          - 3.x (for RS/6000), paging kernel, logical volume manager, i18n;
  3782.            3.2 adds TLI/STREAMS.  SV-based with many enhancements.
  3783.          - AIX/ESA, runs native on S/370 and S/390 mainframes, based on OSF/1.
  3784.          AIX was to have been base for OSF/1 until Mach was chosen instead.
  3785.          I hope this subsection is converging :-)
  3786.  
  3787.       AOS (IBM):  4.3BSD port to IBM PC RT (for educational institutes).
  3788.          Don't confuse with DG's proprietary OS of same name.
  3789.  
  3790.       Arix:  SV
  3791.  
  3792.       A/UX (Apple): SV with Berkeley enhancements, NFS, Mac GUI.  System 6
  3793.          (later System 7) runs as guest of A/UX (opposite of MachTen).
  3794.          Newsgroup: comp.unix.aux.
  3795.          - 2.0:  SVR2 with 4.2BSD, system 6 Mac applications.
  3796.          - 3.0 (1992): SVR2.2 with 4.3BSD and SVR3/4 extensions; X11R4,
  3797.            MacX, TCP/IP, NFS, NIS, RPC/XDR, various shells, UFS or S5FS.
  3798.            System 7 applications.
  3799.          - 4.0 will have/be OSF/1.
  3800.  
  3801.       3B1 (680x0): SV-based, done by Convergent for AT&T.
  3802.          Newsgroup: comp.sys.3b1.
  3803.  
  3804.       BNR/2: stands for BSD Net/2 Release? Includes NetBSD/1, FreeBSD.
  3805.  
  3806.       BOS for Bull's DPX/2 (680x0)
  3807.          - V1 (1990): SVR3 with BSD extensions (FFS, select, sockets),
  3808.            symmetric MP, X11R3
  3809.          - V2 (1 death and continues to
  3810.       work), and the grandchild does whatever the child was originally
  3811.       supposed to.  Since its parent died, it is inherited by init,
  3812.       which will do whatever waiting is needed.  This method is
  3813.       inefficient because it requires an extra fork, but is pretty much
  3814.       completely portable.
  3815.  
  3816. ------------------------------
  3817.  
  3818. Subject: How do I get lines from a pipe ... instead of only in larger blocks?
  3819. From: jik@rtfm.MIT.Edu (Jonathan I. Kamens)
  3820. Date: Sun, 16 Feb 92 20:59:28 -0500
  3821.  
  3822. 3.14) How do I get lines from a pipe as they are written instead of only in
  3823.       larger blocks?
  3824.  
  3825.       The stdio library does buffering differently depending on whether
  3826.       it thinks it's running on a tty.  If it thinks it's on a tty, it
  3827.       does buffering on a per-line basis; if not, it uses a larger
  3828.       buffer than one line.
  3829.  
  3830.       If you have the source code to the client whose buffering you
  3831.       want to disable, you can use setbuf() or setvbuf() to change the
  3832.       buffering.
  3833.  
  3834.       If not, the best you can do is try to convince the program that
  3835.       it's running on a tty by running it under a pty, e.g. by using
  3836.       the "pty" program mentioned in question 3.9.
  3837.  
  3838. ------------------------------
  3839.  
  3840. End of unix/faq Digest part 3 of 7
  3841. **********************************
  3842.  
  3843. -- 
  3844. Ted Timar - tmatimar@isgtec.com
  3845. ISG Technologies Inc., 6509 Airport Road, Mississauga, Ontario, Canada L4V 1S7
  3846. Archive-name: unix-faq/faq/part4
  3847. Version: $Id: part4,v 2.5 1994/04/28 19:25:03 tmatimar Exp tmatimar $
  3848.  
  3849. These seven articles contain the answers to some Frequently Asked
  3850. Questions often seen in comp.unix.questions and comp.unix.shell.
  3851. Please don't ask these questions again, they've been answered plenty
  3852. of times already - and please don't flame someone just because they may
  3853. not have read this particular posting.  Thank you.
  3854.  
  3855. This collection of documents is Copyright (c) 1994, Ted Timar, except
  3856. Part 6, which is Copyright (c) 1994, Pierre Lewis and Ted Timar.
  3857. All rights reserved.  Permission to distribute the collection is
  3858. hereby granted providing that distribution is electronic, no money
  3859. is involved, reasonable attempts are made to use the latest version
  3860. and all credits and this copyright notice are maintained.
  3861. Other requests for distribution will be considered.  All reasonable
  3862. requests will be granted.
  3863.  
  3864. All information here has been contributed with good intentions, but
  3865. none of it is guaranteed either by the contributors or myself to be
  3866. accurate.  The users of this information take all responsibility for
  3867. any damage that may occur.
  3868.  
  3869. Many FAQs, including this one, are available on the archive site
  3870. rtfm.mit.edu in the directory pub/usenet/news.answers.
  3871. The name under which a FAQ is archived appears in the "Archive-Name:"
  3872. line at the top of the article.  This FAQ is archived as
  3873. "unix-faq/faq/part[1-7]".
  3874.  
  3875. These articles are divided approximately as follows:
  3876.  
  3877.       1.*) General questions.
  3878.       2.*) Relatively basic questions, likely to be asked by beginners.
  3879.       3.*) Intermediate questions.
  3880.       4.*) Advanced questions, likely to be asked by people who thought
  3881.            they already knew all of the answers.
  3882.       5.*) Questions pertaining to the various shells, and the differences.
  3883.       6.*) An overview of Unix variants.
  3884.       7.*) An comparison of configuration management systems (RCS, SCCS).
  3885.  
  3886. This article includes answers to:
  3887.  
  3888.       4.1)  How do I read characters from a terminal without requiring the user
  3889.               to hit RETURN?
  3890.       4.2)  How do I check to see if there are characters to be read without
  3891.               actually reading?
  3892.       4.3)  How do I find the name of an open file?
  3893.       4.4)  How can an executing program determine its own pathname?
  3894.       4.5)  How do I use popen() to open a process for reading AND writing?
  3895.       4.6)  How do I sleep() in a C program for less than one second?
  3896.       4.7)  How can I get setuid shell scripts to work?
  3897.       4.8)  How can I find out which user or process has a file open or is using
  3898.             a particular file system (so that I can unmount it?)
  3899.       4.9)  How do I keep track of people who are fingering me?
  3900.       4.10) Is it possible to reconnect a process to a terminal after it has
  3901.             been disconnected, e.g. after starting a program in the background
  3902.             and logging out?
  3903.       4.11) Is it possible to "spy" on a terminal, displaying the output
  3904.             that's appearing on it on another terminal?
  3905.  
  3906. If you're looking for the answer to, say, question 4.5, and want to skip
  3907. everything else, you can search ahead for the regular expression "^4.5)".
  3908.  
  3909. While these are all legitimate questions, they seem to crop up in
  3910. comp.unix.questions or comp.unix.shell on an annual basis, usually
  3911. followed by plenty of replies (only some of which are correct) and then
  3912. a period of griping about how the same questions keep coming up.  You
  3913. may also like to read the monthly article "Answers to Frequently Asked
  3914. Questions" in the newsgroup "news.announce.newusers", which will tell
  3915. you what "UNIX" stands for.
  3916.  
  3917. With the variety of Unix systems in the world, it's hard to guarantee
  3918. that these answers will work everywhere.  Read your local manual pages
  3919. before trying anything suggested here.  If you have suggestions or
  3920. corrections for any of these answers, please send them to to
  3921. tmatimar@isgtec.com.
  3922.  
  3923. ----------------------------------------------------------------------
  3924.  
  3925. Subject: How do I read characters ... without requiring the user to hit RETURN?
  3926. Date: Thu Mar 18 17:16:55 EST 1993
  3927.  
  3928. 4.1)  How do I read characters from a terminal without requiring the user
  3929.       to hit RETURN?
  3930.  
  3931.       Check out cbreak mode in BSD, ~ICANON mode in SysV.
  3932.  
  3933.       If you don't want to tackle setting the terminal parameters
  3934.       yourself (using the "ioctl(2)" system call) you can let the stty
  3935.       program do the work - but this is slow and inefficient, and you
  3936.       should change the code to do it right some time:
  3937.  
  3938.       #include <stdio.h>
  3939.       main()
  3940.       {
  3941.             int c;
  3942.  
  3943.             printf("Hit any character to continue\n");
  3944.             /*
  3945.              * ioctl() would be better here; only lazy
  3946.              * programmers do it this way:
  3947.              */
  3948.             system("/bin/stty cbreak");        /* or "stty raw" */
  3949.             c = getchar();
  3950.             system("/bin/stty -cbreak");
  3951.             printf("Thank you for typing %c.\n", c);
  3952.  
  3953.             exit(0);
  3954.       }
  3955.  
  3956.       Several people have sent me various more correct solutions to
  3957.       this problem.  I'm sorry that I'm not including any of them here,
  3958.       because they really are beyond the scope of this list.
  3959.  
  3960.       You might like to check out the documentation for the "curses"
  3961.       library of portable screen functions.  Often if you're interested
  3962.       in single-character I/O like this, you're also interested in
  3963.       doing some sort of screen display control, and the curses library
  3964.       provides various portable routines for both functions.
  3965.  
  3966. ------------------------------
  3967.  
  3968. Subject: How do I check to see if there are characters to be read ... ?
  3969. Date: Thu Mar 18 17:16:55 EST 1993
  3970.  
  3971. 4.2)  How do I check to see if there are characters to be read without
  3972.       actually reading?
  3973.  
  3974.       Certain versions of UNIX provide ways to check whether characters
  3975.       are currently available to be read from a file descriptor.  In
  3976.       BSD, you can use select(2).  You can also use the FIONREAD ioctl
  3977.       (see tty(4)), which returns the number of characters waiting to
  3978.       be read, but only works on terminals, pipes and sockets.  In
  3979.       System V Release 3, you can use poll(2), but that only works on
  3980.       streams.  In Xenix - and therefore Unix SysV r3.2 and later - the
  3981.       rdchk() system call reports whether a read() call on a given file
  3982.       descriptor will block.
  3983.  
  3984.       There is no way to check whether characters are available to be
  3985.       read from a FILE pointer.  (You could poke around inside stdio
  3986.       data structures to see if the input buffer is nonempty, but that
  3987.       wouldn't work since you'd have no way of knowing what will happen
  3988.       the next time you try to fill the buffer.)
  3989.  
  3990.       Sometimes people ask this question with the intention of writing
  3991.             if (characters available from fd)
  3992.                     read(fd, buf, sizeof buf);
  3993.       in order to get the effect of a nonblocking read.  This is not
  3994.       the best way to do this, because it is possible that characters
  3995.       will be available when you test for availability, but will no
  3996.       longer be available when you call read.  Instead, set the
  3997.       O_NDELAY flag (which is also called FNDELAY under BSD) using the
  3998.       F_SETFL option of fcntl(2).  Older systems (Version 7, 4.1 BSD)
  3999.       don't have O_NDELAY; on these systems the closest you can get to
  4000.       a nonblocking read is to use alarm(2) to time out the read.
  4001.  
  4002. ------------------------------
  4003.  
  4004. Subject: How do I find the name of an open file?
  4005. Date: Thu Mar 18 17:16:55 EST 1993
  4006.  
  4007. 4.3)  How do I find the name of an open file?
  4008.  
  4009.       In general, this is too difficult.  The file descriptor may
  4010.       be attached to a pipe or pty, in which case it has no name.
  4011.       It may be attached to a file that has been removed.  It may
  4012.       have multiple names, due to either hard or symbolic links.
  4013.  
  4014.       If you really need to do this, and be sure you think long
  4015.       and hard about it and have decided that you have no choice,
  4016.       you can use find with the -inum and possibly -xdev option,
  4017.       or you can use ncheck, or you can recreate the functionality
  4018.       of one of these within your program.  Just realize that
  4019.       searching a 600 megabyte filesystem for a file that may not
  4020.       even exist is going to take some time.
  4021.  
  4022. ------------------------------
  4023.  
  4024. Subject: How can an executing program determine its own pathname?
  4025. Date: Thu Mar 18 17:16:55 EST 1993
  4026.  
  4027. 4.4)  How can an executing program determine its own pathname?
  4028.  
  4029.       Your program can look at argv[0]; if it begins with a "/", it is
  4030.       probably the absolute pathname to your program, otherwise your
  4031.       program can look at every directory named in the environment
  4032.       variable PATH and try to find the first one that contains an
  4033.       executable file whose name matches your program's argv[0] (which
  4034.       by convention is the name of the file being executed).  By
  4035.       concatenating that directory and the value of argv[0] you'd
  4036.       probably have the right name.
  4037.  
  4038.       You can't really be sure though, since it is quite legal for one
  4039.       program to exec() another with any value of argv[0] it desires.
  4040.       It is merely a convention that new programs are exec'd with the
  4041.       executable file name in argv[0].
  4042.  
  4043.       For instance, purely a hypothetical example:
  4044.         
  4045.         #include <stdio.h>
  4046.         main()
  4047.         {
  4048.             execl("/usr/games/rogue", "vi Thesis", (char *)NULL);
  4049.         }
  4050.  
  4051.       The executed program thinks its name (its argv[0] value) is
  4052.       "vi Thesis".   (Certain other programs might also think that
  4053.       the name of the program you're currently running is "vi Thesis",
  4054.       but of course this is just a hypothetical example, don't
  4055.       try it yourself :-)
  4056.  
  4057. ------------------------------
  4058.  
  4059. Subject: How do I use popen() to open a process for reading AND writing?
  4060. Date: Thu Mar 18 17:16:55 EST 1993
  4061.  
  4062. 4.5)  How do I use popen() to open a process for reading AND writing?
  4063.  
  4064.       The problem with trying to pipe both input and output to an
  4065.       arbitrary slave process is that deadlock can occur, if both
  4066.       processes are waiting for not-yet-generated input at the same
  4067.       time.  Deadlock can be avoided only by having BOTH sides follow a
  4068.       strict deadlock-free protocol, but since that requires
  4069.       cooperation from the processes it is inappropriate for a
  4070.       popen()-like library function.
  4071.  
  4072.       The 'expect' distribution includes a library of functions that a
  4073.       C programmer can call directly.  One of the functions does the
  4074.       equivalent of a popen for both reading and writing.  It uses ptys
  4075.       rather than pipes, and has no deadlock problem.  It's portable to
  4076.       both BSD and SV.  See the next answer for more about 'expect'.
  4077.  
  4078. ------------------------------
  4079.  
  4080. Subject: How do I sleep() in a C program for less than one second?
  4081. Date: Thu Mar 18 17:16:55 EST 1993
  4082.  
  4083. 4.6)  How do I sleep() in a C program for less than one second?
  4084.  
  4085.       The first thing you need to be aware of is that all you can
  4086.       specify is a MINIMUM amount of delay; the actual delay will
  4087.       depend on scheduling issues such as system load, and could be
  4088.       arbitrarily large if you're unlucky.
  4089.  
  4090.       There is no standard library function that you can count on in
  4091.       all environments for "napping" (the usual name for short
  4092.       sleeps).  Some environments supply a "usleep(n)" function which
  4093.       suspends execution for n microseconds.  If your environment
  4094.       doesn't support usleep(), here are a couple of implementations
  4095.       for BSD and System V environments.
  4096.  
  4097.       The following code is adapted from Doug Gwyn's System V emulation
  4098.       support for 4BSD and exploits the 4BSD select() system call.
  4099.       Doug originally called it 'nap()'; you probably want to call it
  4100.       "usleep()";
  4101.  
  4102.       /*
  4103.             usleep -- support routine for 4.2BSD system call emulations
  4104.             last edit:  29-Oct-1984     D A Gwyn
  4105.       */
  4106.  
  4107.       extern int        select();
  4108.  
  4109.       int
  4110.       usleep( usec )                            /* returns 0 if ok, else -1 */
  4111.             long                usec;           /* delay in microseconds */
  4112.             {
  4113.             static struct                       /* `timeval' */
  4114.                     {
  4115.                     long        tv_sec;         /* seconds */
  4116.                     long        tv_usec;        /* microsecs */
  4117.                     }   delay;          /* _select() timeout */
  4118.  
  4119.             delay.tv_sec = usec / 1000000L;
  4120.             delay.tv_usec = usec % 1000000L;
  4121.  
  4122.             return select( 0, (long *)0, (long *)0, (long *)0, &delay );
  4123.             }
  4124.  
  4125.       On System V you might do it this way:
  4126.  
  4127.       /*
  4128.       subseconds sleeps for System V - or anything that has poll()
  4129.       Don Libes, 4/1/1991
  4130.  
  4131.       The BSD analog to this function is defined in terms of
  4132.       microseconds while poll() is defined in terms of milliseconds.
  4133.       For compatibility, this function provides accuracy "over the long
  4134.       run" by truncating actual requests to milliseconds and
  4135.       accumulating microseconds across calls with the idea that you are
  4136.       probably calling it in a tight loop, and that over the long run,
  4137.       the error will even out.
  4138.  
  4139.       If you aren't calling it in a tight loop, then you almost
  4140.       certainly aren't making microsecond-resolution requests anyway,
  4141.       in which case you don't care about microseconds.  And if you did,
  4142.       you wouldn't be using UNIX anyway because random system
  4143.       indigestion (i.e., scheduling) can make mincemeat out of any
  4144.       timing code.
  4145.  
  4146.       Returns 0 if successful timeout, -1 if unsuccessful.
  4147.  
  4148.       */
  4149.  
  4150.       #include <poll.h>
  4151.  
  4152.       int
  4153.       usleep(usec)
  4154.       unsigned int usec;                /* microseconds */
  4155.       {
  4156.             static subtotal = 0;        /* microseconds */
  4157.             int msec;                   /* milliseconds */
  4158.  
  4159.             /* 'foo' is only here because some versions of 5.3 have
  4160.              * a bug where the first argument to poll() is checked
  4161.              * for a valid memory address even if the second argument is 0.
  4162.              */
  4163.             struct pollfd foo;
  4164.  
  4165.             subtotal += usec;
  4166.             /* if less then 1 msec request, do nothing but remember it */
  4167.             if (subtotal < 1000) return(0);
  4168.             msec = subtotal/1000;
  4169.             subtotal = subtotal%1000;
  4170.             return poll(&foo,(unsigned long)0,msec);
  4171.       }
  4172.  
  4173.       Another possibility for nap()ing on System V, and probably other
  4174.       non-BSD Unices is Jon Zeeff's s5nap package, posted to
  4175.       comp.sources.misc, volume 4.  It does require a installing a
  4176.       device driver, but works flawlessly once installed.  (Its
  4177.       resolution is limited to the kernel HZ value, since it uses the
  4178.       kernel delay() routine.)
  4179.  
  4180. ------------------------------
  4181.  
  4182. Subject: How can I get setuid shell scripts to work?
  4183. Date: Thu Mar 18 17:16:55 EST 1993
  4184.  
  4185. 4.7)  How can I get setuid shell scripts to work?
  4186.  
  4187.       [ This is a long answer, but it's a complicated and frequently-asked
  4188.         question.  Thanks to Maarten Litmaath for this answer, and
  4189.         for the "indir" program mentioned below. ]
  4190.  
  4191.       Let us first assume you are on a UNIX variant (e.g. 4.3BSD or
  4192.       SunOS) that knows about so-called `executable shell scripts'.
  4193.       Such a script must start with a line like:
  4194.  
  4195.         #!/bin/sh
  4196.  
  4197.       The script is called `executable' because just like a real (binary)
  4198.       executable it starts with a so-called `magic number' indicating
  4199.       the type of the executable.  In our case this number is `#!' and
  4200.       the OS takes the rest of the first line as the interpreter for
  4201.       the script, possibly followed by 1 initial option like:
  4202.  
  4203.         #!/bin/sed -f
  4204.  
  4205.       Suppose this script is called `foo' and is found in /bin,
  4206.       then if you type:
  4207.  
  4208.         foo arg1 arg2 arg3
  4209.  
  4210.       the OS will rearrange things as though you had typed:
  4211.  
  4212.         /bin/sed -f /bin/foo arg1 arg2 arg3
  4213.  
  4214.       There is one difference though: if the setuid permission bit for
  4215.       `foo' is set, it will be honored in the first form of the
  4216.       command; if you really type the second form, the OS will honor
  4217.       the permission bits of /bin/sed, which is not setuid, of course.
  4218.  
  4219.       ----------
  4220.  
  4221.       OK, but what if my shell script does NOT start with such a `#!'
  4222.       line or my OS does not know about it?
  4223.  
  4224.       Well, if the shell (or anybody else) tries to execute it, the OS
  4225.       will return an error indication, as the file does not start with
  4226.       a valid magic number.  Upon receiving this indication the shell
  4227.       ASSUMES the file to be a shell script and gives it another try:
  4228.  
  4229.         /bin/sh shell_script arguments
  4230.  
  4231.       But we have already seen that a setuid bit on `shell_script' will
  4232.       NOT be honored in this case!
  4233.  
  4234.       ----------
  4235.  
  4236.       Right, but what about the security risks of setuid shell scripts?
  4237.  
  4238.       Well, suppose the script is called `/etc/setuid_script', starting
  4239.       with:
  4240.  
  4241.         #!/bin/sh
  4242.         
  4243.       Now let us see what happens if we issue the following commands:
  4244.  
  4245.         $ cd /tmp
  4246.         $ ln /etc/setuid_script -i
  4247.         $ PATH=.
  4248.         $ -i
  4249.  
  4250.       We know the last command will be rearranged to:
  4251.  
  4252.         /bin/sh -i
  4253.  
  4254.       But this command will give us an interactive shell, setuid to the
  4255.       owner of the script!
  4256.       Fortunately this security hole can easily be closed by making the
  4257.       first line:
  4258.  
  4259.         #!/bin/sh -
  4260.  
  4261.       The `-' signals the end of the option list: the next argument `-i'
  4262.       will be taken as the name of the file to read commands from, just
  4263.       like it should!
  4264.  
  4265.       ---------
  4266.  
  4267.       There are more serious problems though:
  4268.  
  4269.         $ cd /tmp
  4270.         $ ln /etc/setuid_script temp
  4271.         $ nice -20 temp &
  4272.         $ mv my_script temp
  4273.  
  4274.       The third command will be rearranged to:
  4275.  
  4276.         nice -20 /bin/sh - temp
  4277.  
  4278.       As this command runs so slowly, the fourth command might be able
  4279.       to replace the original `temp' with `my_script' BEFORE `temp' is
  4280.       opened by the shell!  There are 4 ways to fix this security hole:
  4281.  
  4282.         1)  let the OS start setuid scripts in a different, secure way
  4283.             - System V R4 and 4.4BSD use the /dev/fd driver to pass the
  4284.             interpreter a file descriptor for the script
  4285.  
  4286.         2)  let the script be interpreted indirectly, through a frontend
  4287.             that makes sure everything is all right before starting the
  4288.             real interpreter - if you use the `indir' program from
  4289.             comp.sources.unix the setuid script will look like this:
  4290.  
  4291.                 #!/bin/indir -u
  4292.                 #?/bin/sh /etc/setuid_script
  4293.  
  4294.         3)  make a `binary wrapper': a real executable that is setuid and
  4295.             whose only task is to execute the interpreter with the name of
  4296.             the script as an argument
  4297.  
  4298.         4)  make a general `setuid script server' that tries to locate the
  4299.             requested `service' in a database of valid scripts and upon
  4300.             success will start the right interpreter with the right
  4301.             arguments.
  4302.  
  4303.       ---------
  4304.  
  4305.       Now that we have made sure the right file gets interpreted, are
  4306.       there any risks left?
  4307.  
  4308.       Certainly!  For shell scripts you must not forget to set the PATH
  4309.       variable to a safe path explicitly.  Can you figure out why?
  4310.       Also there is the IFS variable that might cause trouble if not
  4311.       set properly.  Other environment variables might turn out to
  4312.       compromise security as well, e.g. SHELL...  Furthermore you must
  4313.       make sure the commands in the script do not allow interactive
  4314.       shell escapes!  Then there is the umask which may have been set
  4315.       to something strange...
  4316.  
  4317.       Etcetera.  You should realise that a setuid script `inherits' all
  4318.       the bugs and security risks of the commands that it calls!
  4319.  
  4320.       All in all we get the impression setuid shell scripts are quite a
  4321.       risky business!  You may be better off writing a C program instead!
  4322.  
  4323. ------------------------------
  4324.  
  4325. Subject: How can I find out which user or process has a file open ... ?
  4326. Date: Thu Mar 18 17:16:55 EST 1993
  4327.  
  4328. 4.8)  How can I find out which user or process has a file open or is using
  4329.       a particular file system (so that I can unmount it?)
  4330.  
  4331.       Use fuser (system V), fstat (BSD), ofiles (public domain) or
  4332.       pff (public domain).  These programs will tell you various things
  4333.       about processes using particular files.
  4334.  
  4335.       A port of the 4.3 BSD fstat to Dynix, SunOS and Ultrix
  4336.       can be found in archives of comp.sources.unix, volume 18.
  4337.  
  4338.       pff is part of the kstuff package, and works on quite a few systems.
  4339.       Instructions for obtaining kstuff are provided in question 3.10.
  4340.  
  4341. ------------------------------
  4342.  
  4343. Subject: How do I keep track of people who are fingering me?
  4344. From: jik@rtfm.MIT.EDU (Jonathan I. Kamens)
  4345. From: malenovi@plains.NoDak.edu (Nikola Malenovic)
  4346. Date: Mon, 23 Nov 1992 16:01:45 -0600
  4347.  
  4348. 4.9)  How do I keep track of people who are fingering me?
  4349.  
  4350.       Generally, you can't find out the userid of someone who is
  4351.       fingering you from a remote machine.  You may be able to
  4352.       find out which machine the remote request is coming from.
  4353.       One possibility, if your system supports it and assuming
  4354.       the finger daemon doesn't object, is to make your .plan file a
  4355.       "named pipe" instead of a plain file.  (Use 'mknod' to do this.)
  4356.  
  4357.       You can then start up a program that will open your .plan file
  4358.       for writing; the open will block until some other process (namely
  4359.       fingerd) opens the .plan for reading.  Now you can whatever you
  4360.       want through this pipe, which lets you show different .plan
  4361.       information every time someone fingers you.
  4362.  
  4363.       Of course, this may not work at all if your system doesn't
  4364.       support named pipes or if your local fingerd insists
  4365.       on having plain .plan files.
  4366.  
  4367.       Your program can also take the opportunity to look at the output
  4368.       of "netstat" and spot where an incoming finger connection is
  4369.       coming from, but this won't get you the remote user.
  4370.  
  4371.       Getting the remote userid would require that the remote site be
  4372.       running an identity service such as RFC 931.  There are now three
  4373.       RFC 931 implementations for popular BSD machines, and several
  4374.       applications (such as the wuarchive ftpd) supporting the server.
  4375.       For more information join the rfc931-users mailing list,
  4376.       rfc931-users-request@kramden.acf.nyu.edu.
  4377.  
  4378.       There are three caveats relating to this answer.  The first is
  4379.       that many NFS systems won't recognize the named pipe correctly.
  4380.       This means that trying to read the pipe on another machine will
  4381.       either block until it times out, or see it as a zero-length file,
  4382.       and never print it.
  4383.  
  4384.       The second problem is that on many systems, fingerd checks that
  4385.       the .plan file contains data (and is readable) before trying to
  4386.       read it.  This will cause remote fingers to miss your .plan file
  4387.       entirely.
  4388.  
  4389.       The third problem is that a system that supports named pipes
  4390.       usually has a fixed number of named pipes available on the
  4391.       system at any given time - check the kernel config file and
  4392.     com>
  4393.  
  4394. 7.13) RCS vs SCCS:  Acknowledgements
  4395.  
  4396.       I would like to thank the following persons for contributing to
  4397.       these articles.  I'd like to add your name to the list--please
  4398.       send comments or more references to Bill Wohler <wohler@newt.com>.
  4399.  
  4400.         Karl Vogel <vogel@c-17igp.wpafb.af.mil>
  4401.         Mark Runyan <runyan@hpcuhc.cup.hp.com>
  4402.         Paul Eggert <eggert@twinsun.com>
  4403.         Greg Henderson <henders@infonode.ingr.com>
  4404.         Dave Goldberg <dsg@mbunix.mitre.org>
  4405.         Rob Kurver <rob@pact.nl>
  4406.         Raymond Chen <rjc@math.princeton.edu>
  4407.         Dwight <dwight@s1.gov>
  4408.  
  4409. ------------------------------
  4410.  
  4411. Subject: Can I get more information on configuration management systems?
  4412. Date: Thu Oct 15 10:27:47 EDT 1992
  4413. From: Ted Timar <tmatimar@isgtec.com>
  4414.  
  4415. 7.14) Can I get more information on configuration management systems?
  4416.  
  4417.       Bill Wohler, who compiled all of the information in this part of
  4418.       the FAQ, has compiled much more information.  This information is
  4419.       available for ftp from ftp.wg.omron.co.jp (133.210.4.4) under
  4420.       "pub/unix-faq/docs/rev-ctl-sys".
  4421.  
  4422. ------------------------------
  4423.  
  4424. End of unix/faq Digest part 7 of 7
  4425. **********************************
  4426.  
  4427. -- 
  4428. Ted Timar - tmatimar@isgtec.com
  4429. ISG Technologies Inc., 6509 Airport Road, Mississauga, Ontario, Canada L4V 1S7
  4430.